Policy sampling to guide losses in training adapters
Patent Information
- Application Number
- PCT/CN2025/082830
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2025-03-17
- Publication Date
- 2026-09-24
Smart Images

Figure CN2025082830_24092026_PF_FP_ABST
Abstract
Description
POLICY SAMPLING TO GUIDE LOSSES IN TRAINING ADAPTERSFIELD
[0001] The present disclosure generally relates to machine learning (ML) models. For example, aspects of the present disclosure are related to systems and techniques for policy sampling to guide losses in training adapters.BACKGROUND
[0002] Machine learning systems (or models) , such as neural networks (e.g., deep neural networks) are widely used for numerous applications, such as generative operations (e.g., to generate images, language / text outputs, etc. ) , object detection, object classification, object tracking, big data analysis, among others. For example, convolutional neural networks (CNNs) are able to extract high-level features, such as facial shapes, from an input image, and use these high-level features to output a probability that, for example, an input image includes a particular object.
[0003] A generative machine learning system can process data to generate desired output content from an input (e.g., a natural language input, input image (s) or video (s) , a noise input such as for diffusion models, etc. ) . For instance, a language-based generative machine learning model (e.g., a large language model (LLM) ) can generate natural language responses from natural language inputs and can incorporate various forms of data, such as audio, images and text. In some cases, a generative machine learning system can include an encoder that processes input features to generate output features (also referred to as embeddings or encodings) and can use the output features to generate relevant output content in a given form (e.g., in a natural language form, as generated images and / or video, as audio, explanation of the content, etc. ) .
[0004] A generative ML system can perform a wide range of tasks such as answering questions, providing explanations, generating creative content, assisting with coding, and offering recommendations. Various tools may be connected to the generative ML system to allow interaction with external systems, such as browsing the Internet, generating images, executing code, etc. Generative ML systems are designed to assist users in solving problems, learning new information, and enhancing productivity.SUMMARY
[0005] The following presents a simplified summary relating to one or more aspects disclosed herein. Thus, the following summary should not be considered an extensive overview relating to all contemplated aspects, nor should the following summary be considered to identify key or critical elements relating to all contemplated aspects or to delineate the scope associated with any particular aspect. Accordingly, the following summary presents certain concepts relating to one or more aspects relating to the mechanisms disclosed herein in a simplified form to precede the detailed description presented below.
[0006] Systems and techniques are described for herein for training a machine learning (ML) model. In one illustrative example, an apparatus for training a ML model is provided. The apparatus includes: at least one memory comprising instructions; and at least one processor coupled to the at least one memory and configured to: generate a first loss based on teacher features from a teacher ML model and student features from a student ML model; generate a second loss based on the student features and a label; combine the first loss and the second loss to generate a combined loss; and train the student ML model based on the combined loss.
[0007] As another example, a method for training a machine learning (ML) model is provided. The method includes: generating a first loss based on teacher features from a teacher ML model and student features from a student ML model; generating a second loss based on the student features and a label; combining the first loss and the second loss to generate a combined loss; and training the student ML model based on the combined loss.
[0008] In another example, a non-transitory computer-readable medium having stored thereon instructions is provided. The instructions, when executed by at least one processor, cause the at least one processor to: generate a first loss based on teacher features from a teacher ML model and student features from a student ML model; generate a second loss based on the student features and a label; combine the first loss and the second loss to generate a combined loss; and train the student ML model based on the combined loss.
[0009] For another example, an apparatus for training a machine learning (ML) model is provided. The apparatus includes: means for generating a first loss based on teacher features from a teacher ML model and student features from a student ML model; means for generating a second loss based on the student features and a label; means for combining the first loss and the second loss to generate a combined loss; and means for training the student ML model based on the combined loss.
[0010] In some aspects, one or more of the apparatuses described herein comprises a mobile device (e.g., a mobile telephone or so-called “smart phone” , a tablet computer, or other type of mobile device) , a wearable device, an extended reality device (e.g., a virtual reality (VR) device, an augmented reality (AR) device, or a mixed reality (MR) device) , a personal computer, a laptop computer, a video server, a television (e.g., a network-connected television) , a vehicle (or a computing device of a vehicle) , or other device. In some aspects, the apparatus (es) include at least one camera for capturing one or more images or video frames. For example, the apparatus (es) can include a camera (e.g., an RGB camera) or multiple cameras for capturing one or more images and / or one or more videos including video frames. In some aspects, the apparatus (es) can include a display for displaying one or more images, videos, notifications, or other displayable data. In some aspects, the apparatus (es) can include a transmitter configured to transmit one or more video frame and / or syntax data over a transmission medium to at least one device. In some aspects, the processor includes a neural processing unit (NPU) , a central processing unit (CPU) , a graphics processing unit (GPU) , or other processing device or component.
[0011] This summary is not intended to identify key or essential features of the claimed subject matter, nor is it intended to be used in isolation to determine the scope of the claimed subject matter. The subject matter should be understood by reference to appropriate portions of the entire specification of this patent, any or all drawings, and each claim.
[0012] The foregoing, together with other features and embodiments, will become more apparent upon referring to the following specification, claims, and accompanying drawings.BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Illustrative embodiments of the present application are described in detail below with reference to the following figures:
[0014] FIG. 1 illustrates an example implementation of a system, in accordance with some examples;
[0015] FIG. 2 is a block diagram illustrating a multimodal generative ML system for generating natural language responses based on natural language input from a prompt and any additional information;
[0016] FIG. 3 is a conceptual block diagram of a generative response engine that is configured for multimodal input and output in accordance with some aspects of the disclosure;
[0017] FIG. 4 is a block diagram illustrating an example of a system including a base model and various adapters, in accordance with aspects of the disclosure;
[0018] FIG. 5 is a block diagram illustration an example of knowledge distillation, in accordance with aspects of the present disclosure;
[0019] FIG. 6 is a block diagram illustrating an architecture for a technique for using policy sampling to guide losses for training adapters, in accordance with aspects of the present disclosure;
[0020] FIG. 7 is a flow diagram illustrating a process for image processing, in accordance with aspects of the present disclosure;
[0021] FIG. 8 provides two sets of images that show the forward diffusion process (which is fixed) and the reverse diffusion process (which is learned) of a diffusion model, in accordance with some aspects;
[0022] FIG. 9 is a diagram illustrating how diffusion data is distributed from initial data to noise using a diffusion model in the forward diffusion direction, in accordance with some aspects;
[0023] FIG. 10 is a diagram illustrating a U-Net architecture for a diffusion model, in accordance with some aspects;
[0024] FIG. 11 is a block diagram illustrating an example of a deep learning neural network that can be used to implement a perception module and / or one or more validation modules, according to some aspects;
[0025] FIG. 12 is a block diagram illustrating an example of a convolutional neural network (CNN) , according to various aspects of the present disclosure;
[0026] FIG. 13 is a block diagram of an example transformer in accordance with some aspects of the disclosure; and
[0027] FIG. 14 illustrates an example computing device architecture of an example computing device which can implement the various techniques described herein.DETAILED DESCRIPTION
[0028] Certain aspects and embodiments of this disclosure are provided below. Some of these aspects and embodiments may be applied independently and some of them may be applied in combination as would be apparent to those of skill in the art. In the following description, for the purposes of explanation, specific details are set forth in order to provide a thorough understanding of embodiments of the application. However, it will be apparent that various embodiments may be practiced without these specific details. The figures and description are not intended to be restrictive.
[0029] The ensuing description provides example embodiments only, and is not intended to limit the scope, applicability, or configuration of the disclosure. Rather, the ensuing description of the example embodiments will provide those skilled in the art with an enabling description for implementing an example embodiment. It should be understood that various changes may be made in the function and arrangement of elements without departing from the spirit and scope of the application as set forth in the appended claims.
[0030] Machine learning models can be trained to perform various functions and / or provide various types of outputs. For instance, some generative machine learning models can provide a conversational interface that uses natural language prompts as inputs, such as text or voice. In some examples, a user can provide an input prompt in natural language to the generative machine learning model, and the generative machine learning model can provide a response in natural language form. The input prompt and the output response can optionally be combined with one or more other types of information or data, such as images or files.
[0031] Previously trained machine learning models, such as generative machine learning models, can be fine-tuned to improve performance of the machine learning models for specific tasks. Fine-tuning can involve adapting a pre-trained machine learning model (e.g., a pre-trained generative machine learning model or other type of machine learning model) to a specific task by updating parameters (e.g., weights and / or other parameters) of the machine learning model using task-specific training data. The fine-tuning process allows the machine learning model to leverage its pre-existing knowledge while specializing in new tasks. Fine-tuning typically requires less data and compute than fully training a previously untrained machine learning model. Fine-tuning can thus be useful for improving performance of machine learning models on domain-specific tasks without sacrificing the benefits of large-scale pretraining.
[0032] One technique for fine tuning machine learning models is to use an adapter, such as a Low-Rank Adapter (LoRA) . An adapter is a lightweight trainable model that connects to different layers (or blocks) of a machine learning model (e.g., a first layer of one adapter connected to a first layer of the model, a second layer of the adapter connected to a second layer of the model, etc. ) . Adapters can be used to efficiently adapt large pre-trained models to specific tasks with minimal computational cost and resource usage. Adapters (e.g., a LoRA) can be trained to generalize task-specific information to a frozen (e.g., immutable) pre-trained machine learning model.
[0033] For instance, LoRA introduces lightweight trainable modules parameterized as low-rank matrices into an original (e.g., pre-trained) machine learning model to capture task-specific information while the original machine learning model parameters remain frozen, preserving the pre-trained knowledge of the machine learning model. Training a LoRA can include injecting low-rank layers into certain layers of the base model (e.g., attention layers in a transformer model, feedforward layers in the transformer model, convolutional layers in a transformer and / or convolutional model, etc. ) to optimize the layers during training and reduce the number of overall parameters that need to be updated. LoRA can be used to efficiently adapt large pre-trained models to specific tasks with minimal computational cost and resource usage. For example, LoRA may be used to fine-tune a pre-trained model for downstream tasks, such as style adaptation, tone, etc. Such a technique can be performed to overcome the computational challenges of fine-tuning large machine learning models, such as when working with a smaller dataset.
[0034] While machine learning models (e.g., neural networks) are powerful architectures capable of a wide range of useful tasks, such as recognizing objects in image data, they are likewise highly resource dependent. For example, neural networks may require significant compute, memory, power, and / or time resources for training and / or for inferencing. These resource requirements may significantly limit the ability to train and deploy neural networks to certain types of devices and for certain use cases. For instance, training of machine learning models may be a computationally intensive process that can take a relatively long time, a large quantity of training data, and many operations.
[0035] Quantization is a method of mapping continuous values to a smaller set of discrete finite values. For example, quantization approximates real-world values (e.g., floating point values) with representative values (e.g., integer values) that limit the precision and range of the original input. When applied to machine learning, such as to a neural network, quantization may significantly reduce resource usage for both training and inferencing. For example, performing massive numbers of integer operations during training of or inferencing with a quantized (e.g., reduced-precision) neural network may be significantly more efficient in terms of resource usage as compared to performing floating point operations with an unquantized (e.g., full-precision) neural network processing the same input data.
[0036] Quantization of trained machine learning models allows quantized trained machine learning models to be efficiently deployed on various devices. Quantization may allow a quantized trained machine learning model to perform operations (e.g., at the inference phase of operation) on a device relatively quickly. Quantization may include changing a format of parameters (e.g., weights and activations) of a machine learning model from the format in which the machine learning model was trained to a different format.
[0037] Post-Training Quantization (PTQ) is a process by which a trained machine learning model is quantized. For example, during training, a machine learning model may store parameters (e.g., weights) according to a first format that may allow a high degree of precision. For example, during training, the model may store parameters as floating-point numbers, such as 16-bit floating point numbers, which may be referred to as float16 or FP16, or 32-bit floating point numbers, which may be referred to as float32 or FP32. According to PTQ, after training is performed to generate the trained machine learning model and before the trained machine learning model is deployed onto a device for use by a device, the model may be quantized by, in part, changing the format used to store the parameters of the model from the first format to a second format (e.g., an integer format where the parameters are represented as integer numbers instead of floating point numbers) . The second format may use less memory and / or be less computational expensive to use. For example, after quantization, the model may store parameters as integer numbers such as 16-bit integer numbers (which may be referred to as Int16) , 8-bit integer numbers (which may be referred to as Int8) , 4-bit integer numbers (which may be referred to as Int4) , etc. It may be less computationally expensive to store and / or operate using integer numbers than floating point numbers. Thus, a device may conserve power and / or processing time when using a quantized trained machine learning model as compared with using an unquantized trained machine learning model. Accordingly, it may be advantageous to quantize machine learning models.
[0038] Quantized Aware Training (QAT) is another quantization technique that allows a machine learning model to adapt to quantization during training, resulting in better performance after actual quantization is performed as compared to quantizing a fully trained model (e.g., using PTQ) . For example, using QAT, a machine learning model can be trained while simulating effects of actual quantization of weights and / or activations of the machine learning model during training. QAT can help minimize accuracy loss when the machine learning model is eventually quantized to a different format, such as from floating point to an integer format, such as Int8.
[0039] In various aspects of the present disclosure, the term “quantize, ” “quantizing, ” and like terms may be used as a verb and may be applied to machine learning models, and / or layers of a trained machine learning model. In such cases the term “quantize, ” “quantizing, ” and like terms may refer to quantizing parameters (e.g., weights and / or activations) as stored in the of the respective machine learning models and / or layers. For example, a trained machine learning model may include weights (e.g., numerical values) . During training, and after training, the weights may be stored in the trained machine learning model in a first format (e.g., float16) . Quantizing the trained machine learning model may include changing the weights from the first format to a second format (e.g., Int8) .
[0040] Further, machine learning models may include activations. Activations can refer to values used as inputs and / or outputs of various functions, operations, and / or layers (or blocks or modules) of the machine learning model. The activations may have a certain format. For example, a function (of a particular layer) may expect to receive values formatted according to the certain format. For instance, the function may read the values from memory according to the certain format. Further, the function may output other values (e.g., based on processing the values read from memory by the function) according to a particular format (which may or may not be the same as the certain format) . For instance, the function may write the other values to memory in the particular format. For example, an unquantized trained machine learning model may use FP16 to pass values between functions (e.g., outputting values from one function and reading the values by another function) . The activations of the machine learning model can also be quantized. For example, quantizing activations may refer to obtaining values calculated by a layer (e.g., an output of an activation function of the layer) and in the format of discrete values. For instance, the values may be represented with fewer bits, such as 8-bit or 16-bit integer numbers instead of 32-bit floating point numbers. After quantization of the activations the machine learning model is configured to process and / or output, the quantized trained machine learning model may use Int8 or Int16 to pass the values between functions. The term “quantize, ” “quantizing, ” and like terms may refer to changing how activations are stored and / or used in a quantized machine learning model.
[0041] Quantizing numbers can result in a loss of precision. Quantizing a trained machine learning model can result in degradation of the model. In the present disclosure, the term “noise” is used to describe a degree of difference between outputs of an unquantized trained machine learning model and the trained machine learning model after being quantized (given the same inputs) . For example, a trained machine learning model may be quantized. The unquantized trained machine learning model may be provided an input, the quantized trained machine learning model may be provided the same input. Outputs of the models may be compared. A degree of difference between the outputs may be described as noise. Noise may be a way to describe degradation of a quantized machine learning model.
[0042] In some cases, a quantization loss (e.g., noise introduced by the quantization) may dominate the training gradient (e.g., slope of gradient in a graph toward a lower error) , making optimization of a quantized ML model for a task difficult. Additionally, sparse quantization activations and weights may introduce random jitter, making convergence for the quantized ML model to optimized weights difficult. In some cases, while QAT can improve the performance of a quantized ML model, there can still be a significant gap between the quantized ML as the base ML model.
[0043] Systems, apparatuses, electronic devices, methods (also referred to as processes) , and computer-readable media (collectively referred to herein as “systems and techniques” ) are described for training ML models. For example, a pretrained base ML model may be a non-quantized model that may be quantized to generate a quantized ML model. The pretrained ML model may be used as a teacher ML model to further train the quantized ML model or student ML model. In some cases, an input may be provided to both the teacher ML model and the student ML model to generate output that may be evaluated to determine a loss value. This loss value may be used to train the student ML model. In some cases, the output may be logits. Logits may be raw, unnormalized scores (e.g., predictions) that may be output by a layer of the ML model before an activation function, such as softmax, is applied by another layer of the ML model.
[0044] In some aspects, a first loss may be generated based on logits from the teacher ML model and student logits from the student ML model. A second loss may be generated based of the student logits and a label. In some cases, the first loss may be a distribution loss, and the second loss may be a task loss. In some examples, the distribution loss may be a generalized Kullback-Leibler divergence (GKLD) loss. In some examples, the task loss may be a mean cross-entropy (MCE) loss. In some cases, the task loss may be a smoothing MCE loss. A smoothing MCE loss may be generated based on a one hot vector and an equal hot vector.
[0045] The first loss and the second loss may be combined into a combined loss function to generate a combined loss. The student ML model may be trained based on the combined loss. In some cases, the student ML model may include an adapter, such as a Low-Rank Adapter (LoRA) . An adapter is a lightweight trainable model that connects to different layers (or blocks) of a machine learning model. In some cases, training the student ML model may include training an adapter of the student ML model. For example, the student ML model have frozen weights and the adapter may be trained to mitigate quantization losses of a quantized ML model.
[0046] In some cases, the first loss may be generated based on logits that are obtained using on-policy sampling. On-policy sampling may allow a student ML model being trained to generate a sequence of multiple predicted values, such as a sentence, in response to an input. A loss may be determined across the multiple predicted values as a whole in comparison to a ground truth sequence. In some cases, on policy group sampling may be used. For example, the on-policy sampling may be used to generate multiple sequences based on a number of top probable sequences (e.g., top K probable sequences) . Loss values may be generated for the multiple sequences as compared to ground truth sequences. In some cases, one or more sequences of the multiple sequences, may be rejected based on a length of the sequence. For example, longer sequences are more likely to be linked with less confident predictions from the student ML model and longer sequences may be rejected. In some cases, the sequences may be rejected have a length that is longer than a median length of the multiple sequences.
[0047] Various aspects of the present disclosure will be described with respect to the figures.
[0048] FIG. 1 illustrates an example implementation of a system 100, which may include a central processing unit (CPU) , configured to perform one or more of the functions described herein. System 100, which may include a central processing unit (CPU 102) (which may be a multi-core CPU) . Parameters or variables (e.g., neural signals and synaptic weights) , system parameters associated with a computational device (e.g., neural network with weights) , task information, among other information may be stored in a memory block associated with a neural processing unit (NPU 108) , in a memory block associated with a CPU 102, in a memory block associated with a graphics processing unit (GPU 104) , in a memory block associated with a digital signal processor (DSP 106) , in a memory 116, and / or may be distributed across multiple blocks. Instructions executed at the CPU 102 may be loaded from a program memory associated with the CPU 102 or may be loaded from memory 116.
[0049] The system 100 may also include additional processing blocks tailored to specific functions, such as the GPU 104, the DSP 106, a connectivity engine 118, which may include fifth generation (5G) connectivity, fourth generation long term evolution (4G LTE) connectivity, Wi-Fi connectivity, USB connectivity, Bluetooth connectivity, and the like, and a multimedia processor 112 that may, for example, detect and recognize gestures. In one implementation, the NPU is implemented in the CPU 102, the DSP 106, and / or the GPU 104. The system 100 may also include one or more sensor processor (s) 114, one or more image signal processors (ISP (s) 110) , and / or navigation engine 120, which may include a global positioning system. In some examples, the sensor processor (s) 114 can be associated with or connected to one or more sensors for providing sensor input (s) to the sensor processor (s) 114. For example, the one or more sensors and sensor processor (s) 114 can be provided in, coupled to, or otherwise associated with a same computing device.
[0050] The system 100 may be implemented as a system on a chip (SoC) . The system 100 may be based on an Advanced Reduced Instruction Set Computer (RISC) Machine (ARM) instruction set. The system 100 and / or components thereof may be configured to perform machine learning techniques according to aspects of the present disclosure discussed herein. For example, the system 100 and / or components thereof may be configured to implement a machine learning model (e.g., a quantized trained machine learning model) as described herein and / or according to aspects of the present disclosure.
[0051] Machine learning (ML) can be considered a subset of artificial intelligence (AI) . ML systems can include algorithms and statistical models that computer systems can use to perform various tasks by relying on patterns and inference, without the use of explicit instructions. One example of a ML system is a neural network (also referred to as an artificial neural network) , which may include an interconnected group of artificial neurons (e.g., neuron models) . Neural networks may be used for various applications and / or devices, such as image and / or video coding, image analysis and / or computer vision applications, Internet Protocol (IP) cameras, Internet of Things (IoT) devices, autonomous vehicles, service robots, among others.
[0052] Individual nodes in a neural network may emulate biological neurons by taking input data and performing simple operations on the data. The results of the simple operations performed on the input data are selectively passed on to other neurons. Weight values are associated with each vector and node in the network, and these values constrain how input data is related to output data. For example, the input data of each node may be multiplied by a corresponding weight value, and the products may be summed. The sum of the products may be adjusted by an optional bias, and an activation function may be applied to the result, yielding the node’s output signal or “output activation” (sometimes referred to as a feature map or an activation map) . The weight values may initially be determined by an iterative flow of training data through the network (e.g., weight values are established during a training phase in which the network learns how to identify particular classes by their typical input data characteristics) .
[0053] Different types of neural networks exist, such as convolutional neural networks (CNNs) , recurrent neural networks (RNNs) , generative adversarial networks (GANs) , multilayer perceptron (MLP) neural networks, transformer neural networks, diffusion-based neural networks, among others. For instance, convolutional neural networks (CNNs) are a type of feed-forward artificial neural network. Convolutional neural networks may include collections of artificial neurons that each have a receptive field (e.g., a spatially localized region of an input space) and that collectively tile an input space. RNNs work on the principle of saving the output of a layer and feeding this output back to the input to help in predicting an outcome of the layer. A GAN is a form of generative neural network that can learn patterns in input data so that the neural network model can generate new synthetic outputs that reasonably could have been from the original dataset. A GAN can include two neural networks that operate together, including a generative neural network that generates a synthesized output and a discriminative neural network that evaluates the output for authenticity. In MLP neural networks, data may be fed into an input layer, and one or more hidden layers provide levels of abstraction to the data. Predictions may then be made on an output layer based on the abstracted data.
[0054] Deep learning (DL) is one example of a machine learning technique and can be considered a subset of ML. Many DL approaches are based on a neural network, such as an RNN or a CNN, and utilize multiple layers. The use of multiple layers in deep neural networks can permit progressively higher-level features to be extracted from a given input of raw data. For example, the output of a first layer of artificial neurons becomes an input to a second layer of artificial neurons, the output of a second layer of artificial neurons becomes an input to a third layer of artificial neurons, and so on. Layers that are located between the input and output of the overall deep neural network are often referred to as hidden layers. The hidden layers learn (e.g., are trained) to transform an intermediate input from a preceding layer into a slightly more abstract and composite representation that can be provided to a subsequent layer, until a final or desired representation is obtained as the final output of the deep neural network.
[0055] As noted above, a neural network is an example of a machine learning system, and can include an input layer, one or more hidden layers, and an output layer. Data is provided from input nodes of the input layer, processing is performed by hidden nodes of the one or more hidden layers, and an output is produced through output nodes of the output layer. Deep learning networks typically include multiple hidden layers. Each layer of the neural network can include feature maps or activation maps that can include artificial neurons (or nodes) . A feature map can include a filter, a kernel, or the like. The nodes can include one or more weights used to indicate an importance of the nodes of one or more of the layers. In some cases, a deep learning network can have a series of many hidden layers, with early layers being used to determine simple and low-level characteristics of an input, and later layers building up a hierarchy of more complex and abstract characteristics.
[0056] A deep learning architecture may learn a hierarchy of features. If presented with visual data, for example, the first layer may learn to recognize relatively simple features, such as edges, in the input stream. In another example, if presented with auditory data, the first layer may learn to recognize spectral power in specific frequencies. The second layer, taking the output of the first layer as input, may learn to recognize combinations of features, such as simple shapes for visual data or combinations of sounds for auditory data. For instance, higher layers may learn to represent complex shapes in visual data or words in auditory data. Still higher layers may learn to recognize common visual objects or spoken phrases.
[0057] Deep learning architectures may perform especially well when applied to problems that have a natural hierarchical structure. For example, the classification of motorized vehicles may benefit from first learning to recognize wheels, windshields, and other features. These features may be combined at higher layers in different ways to recognize cars, trucks, and airplanes.
[0058] Neural networks may be designed with a variety of connectivity patterns. In feed-forward networks, information is passed from lower to higher layers, with each neuron in a given layer communicating to neurons in higher layers. A hierarchical representation may be built up in successive layers of a feed-forward network, as described above. Neural networks may also have recurrent or feedback (also called top-down) connections. In a recurrent connection, the output from a neuron in a given layer may be communicated to another neuron in the same layer. A recurrent architecture may be helpful in recognizing patterns that span more than one of the input data chunks that are delivered to the neural network in a sequence. A connection from a neuron in a given layer to a neuron in a lower layer is called a feedback (or top-down) connection. A network with many feedback connections may be helpful when the recognition of a high-level concept may aid in discriminating the particular low-level features of an input.
[0059] FIG. 2 is a block diagram illustrating a multimodal generative ML system 200 for generating natural language responses based on natural language input from a prompt 202 and any additional information. A multimodal machine learning system is a machine learning model that receives, processes, and outputs data in multiple forms. For example, the input prompt may include text, images, and audio.
[0060] For example, the multimodal generative ML system 200 includes a plurality of encoders 204 that are each configured to encode different modes of content (e.g., text, images, audio, etc. ) into different tokens within a common embedding space. For example, a text input may be segmented based on different techniques (e.g., paragraph, sentence, etc. ) and encoded by a text encoder (from the encoders 204) into tokens. In another example, one or more images can be provided to an image encoder (from the encoders 204) that extracts features associated with the image and generates tokens representing the visual features. In another example, audio can be provided to an audio encoder (from the encoders 204) that extracts features associated with the image and generates tokens representing the audio features. In the case of audio, the audio encoder can identify features that can include formants that characterize resonant frequencies in speech, rhythmic features related to timing and tempo, and harmonic features that describe the relationship between fundamental frequencies and their harmonics.
[0061] The different tokens from the plurality of encoders are provided to combiner 206. The combiner 206 can combine the tokens based on the order in which they are presented. For example, the input into the encoder may be an array of primitive values. A primitive value is an immutable data type provided by a programming language and includes values that represent a single piece of data (e.g., number, string, Boolean, etc. ) rather than a complex object or reference. A non-limiting example prompt may include a byte array (e.g., an unsigned 8-byte integer array or uint8array) , and another string. The byte array may be audio, images, or other content that can be processed by the encoders 204. In some aspects, the combiner 206 is configured to concatenate the different tokens in order based on the array to preserve the semantic order of features and provide the tokens to the generative machine learning model 208.
[0062] The generative machine learning model 208 is configured to receive the tokens and generate a natural language response 212 based on the tokens and the prompt 202. Generative machine learning model 208 may include one or more models 210 (e.g., transformer neural network (s) , diffusion model (s) , fully connected layer (s) , multilayer perceptrons (MLPs) , any combination thereof, and / or other models) . The one or more models 210 of the generative machine learning model 208 are configured to process the tokens and extract different types of features that are relevant to the prompt 202. For example, the prompt 202 can be a query for a particular type of information. The one or more models of the generative machine learning model 208 can perform different tasks related to the query, such as writing code to perform a particular function, generating an image based on an input image with expressed modifications, generate an image without any input image, and so forth.
[0063] The generative machine learning model 208 may include different components, such as a featurization engine to identify different types of features, an inference engine to identify inferences within the text (e.g., pronoun usage and corresponding disambiguation functions) , data retrieval engines (e.g., to identify features related to a particular concept observed by the generative machine learning model 208) , and so forth. The generative machine learning model 208 may also include different types of models and engines to synthesize a coherent contextual output, such as to synthesize the input content and information that is responsive to tasks embedded within the text. For example, the generative machine learning model 208 may include a predictive output engine (not shown) that is configured to generate a sequence of words that is most likely contextually correct and to provide a coherent and contextually relevant answer. For instance, the predictive output generation engine can generate responses by sampling from the probability distribution of possible words and sequences based on patterns observed during training. The generative machine learning model 208 may also include a predictive output generation engine to generate multiple responses that are potentially relevant and coherent with respect to the prompt 202. The generative machine learning model 208 may also include an output validation engine configured to evaluate the generated responses based on certain criteria. Non-limiting examples of criteria to evaluate generated responses include relevance to the prompt, coherence, fluency, and adherence to specific guidelines or rules. Based on the evaluation, the output validation engine may select and output the most appropriate response.
[0064] As noted above, the generative machine learning model 208 may include various types of models (e.g., machine learning models) , such as a transformer. A transformer is a neural network architecture that can be trained to perform one or more natural language processing (NLP) tasks, such as language translation, sentiment analysis, and text summarization. Conventional traditional recurrent neural networks (RNNs) process data in sequence. A transformer or transformer network can process input in parallel and can thus be faster and more efficient than sequential training and processing. In some aspects, a transformer can use a self-attention mechanism (e.g., one or more self-attention layers) , which allows the transformer to identify the most relevant parts of the input text or content (e.g., audio or video) . In some cases, a transformer can also use a cross-attention mechanism (e.g., one or more cross-attention layers) which uses other content or data to determine the most relevant parts of the input. For example, cross-attention mechanisms are useful in sequential content such as a stream of data, such as optical flow, and other computer vision techniques.
[0065] A transformer neural network can include a multi-layer encoder-decoder architecture. For instance, an encoder of the encoder-decoder architecture can receive text as input, convert the input text into a sequence of hidden representations, and capture the meaning of the text at different levels of abstraction. A decoder of the encoder-decoder architecture can then process the representations output from the decoder to generate an output sequence, such as a text translation or a summary. The encoder and decoder can be trained together using supervised learning, unsupervised learning, or a combination of supervised and unsupervised learning techniques, such as maximum likelihood estimation and self-supervised pretraining. Illustrative examples of transformer engines include a BERT model, a Text-to-Text Transfer Transformer (T5) , biomedical BERT (BioBERT) , scientific BERT (SciBERT) , and the SPECTER model for document-level representation learning. In some aspects, multiple transformer engines may be used to generate different tokens.
[0066] In some aspects, the generative machine learning model 208 may be executed using a neural engine (or multiple neural engines) for on-device execution, such as a neural processing unit (NPU) , a neural signal processor (NSP) , a digital signal processor (DSP) , any combination thereof, and / or other neural engine. The neural engine can include a plurality of neural processing cores that are configured to parallelize operations associated with neural networks. A neural processing core can include arrays of multiply-accumulate (MAC) units and specialized instructions that are optimized for matrix operations, such as convolution and matrix multiplication. The neural processing core can receive input data and perform matrix transformations and nonlinear activation functions to break down and parallelize matrix operations. The neural processing core can perform tasks such as inference (e.g., runtime operation of a machine learning model) or training of deep learning models. The neural processing core can accelerate tasks by parallelization of larger computations that can be performed in parallel (e.g., matrix operations associated with neural networks) . For instance, the neural engine may perform computer vision tasks such as object recognition. In some cases, the neural engine can be implemented based on various ML libraries such as PyTorch, which interfaces with the compute unified device architecture (CUDA) to parallelize operations.
[0067] In some aspects, the generative machine learning model 208 may be a small generative model that has fewer parameters, fewer layers, fewer neurons, or a simpler architecture compared to larger models. A small generative model may not capture the full complexity of the underlying data distribution as effectively as larger models but can still be useful in scenarios where computational resources are limited or where a simpler model is sufficient for the task. Small generative models can also be easier to train and interpret, making them suitable for certain applications. For example, ChatGPT-3.5 has 175 billion parameters that results in a size of 1.4 Terabytes (TB) for a model implemented with double-precision floating point numbers. A smaller model may have a simpler architecture, use fewer parameters (e.g., 10 million) , and use less precise numbers (e.g., single-precision floating point numbers) resulting in a size of 38 Megabytes (MB) .
[0068] In addition, small models benefit from increased training based on local execution and data specific to a local device and a user of that local device. An additional benefit to small models is increased privacy because the information is not transmitted over the network and only relies on information requested by the user or usage at the local device.
[0069] FIG. 3 is a conceptual block diagram of a generative response engine 300 that is configured for multimodal input and output in accordance with some aspects of the disclosure. In some aspects, the generative response engine 300 is configured to receive a prompt 302 (e.g., from a user, an application programming interface (API) request, etc. ) and perform various processing to generate a response 304 that is responsive to the prompt 302 that is contextually accurate. In some aspects, the prompt 302 may be an array of primitive values, such as text, binary data (byte arrays, etc. For example, the prompt may be a union type that combines different types of primitive data (e.g., string uint8array in JavaScript) .
[0070] The generative response engine 300 includes a generative machine learning model 318. In some aspects, the generative response engine 300 includes a plurality of adapters (e.g., LoRA) that are trained to improve performance of a base machine learning model (also referred to as a base model) of the generative response engine 300 during inference. The plurality of adapters can be trained to perform different tasks. For example, a first adapter may be trained to perform a first task, and a second adapter a second task and so forth. In this manner, the independently trained adapters are configured to prevent the generative response engine 300 from defaulting to the application of the base model’s weights (which can be referred to as base model weights or base weights) and allow the combination of the base model and the adapters to accurately provide specialized responses that correspond to the fine tuning.
[0071] The generative response engine 300 includes various components, such as a segmenter 310, a classifier 312, a plurality of encoders 314, a combiner 316, and the generative machine learning model 318. The segmenter 310 is configured to segment different content into different portions based on various limitations, such as text size, image size, and so forth. In some cases, the segmenter 310 may also reduce the scope of content (e.g., by reducing a size of an input image) based on limitations of one or more machine learning models of the generative response engine 300. For example, the machine learning model (s) may be trained on a particular size input to extract important features. The segmenter 310 may also segment text into different chunks, such as into individual sentences or paragraphs.
[0072] In some aspects, the classifier 312 may be configured to classify the input. For example, the classifier 312 may be configured to generate embeddings that represent features associated with the input (e.g., segmented text, images, etc. ) in a vector space. An embedding is a representation of a discrete object, such as a word, a document, or an image, as a continuous vector in a multi-dimensional space. An embedding captures the semantic or structural relationships between the objects, such that similar objects are mapped to nearby vectors, and dissimilar objects are mapped to distant vectors. Embeddings are commonly used in machine learning, computer vision, and natural language processing tasks, such as language modeling, sentiment analysis, and machine translation. Embeddings can be learned from large corpora of data using unsupervised learning algorithms, such as word2vec, GloVe, or fastText, which optimize the embeddings based on the co-occurrence or context of the objects in the data. Once learned, embeddings can be used to improve the performance of downstream tasks by providing a more meaningful and compact representation of the objects. In some aspects, the classifications are provided to the generative machine learning model 318 to activate specific learned domains.
[0073] In some cases, the classifier 312 may be configured to classify the input based on a plurality of clusters. The plurality of clusters may represent different semantic spaces for the operation of the generative response engine 300. The plurality of clusters may be related to different specialized tasks, data, or other operations and represent different domains of the generative response engine 300. For example, a generative model trained for customer service may need to learn different domains of knowledge, such as identification of products or services, accounting and billing information, a corpus of documents to help diagnose problems or provide information, and so forth. The plurality of clusters can be determined based on the input and output from the generative response engine 300.
[0074] In some cases, the classifier 312 may generate a probability for the prompt 302 (e.g., for each cluster) based on the output from the segmenter 310. The probability represents a likelihood that the prompt 302 is associated with features (e.g., features in a corresponding cluster) . In some aspects, the classifier 312 provides the probabilities associated with each cluster and the embeddings to the generative machine learning model 318.
[0075] The segmented portions of the prompt 302 can then be provided as input to a plurality of encoders 314 (e.g., the encoders 204 in FIG. 2) to extract various features and generate tokens associated with those features. In some aspects, each encoder 314 is configured for a different modality or different type of input. For example, the generative response engine 300 may include an encoder 314 for encoding text, an encoder 314 for encoding images, an encoder 314 for encoding audio, etc. There may be additional encoders based on the different modalities. For example, there may be an encoder 314 for handling different types of documents (e.g., PDF, etc. ) .
[0076] The combiner 316 (e.g., the combiner 206 in FIG. 2) receives the tokens from the encoders 314 and synthesizes tokens that represent the prompt 302. For example, the combiner 316 can be configured to concatenate the tokens from the encoders 314 in the correct order to preserve the semantic context of the content. In some cases, the encoders 314 may be configured to execute the encoding operations in parallel and because different content may be encoded at different rates, the tokens may be received out of order. The combiner 316 may receive information (e.g., from the segmenter 310 and / or from the encoders 314) to identify how to sequence the embeddings into an input suitable for the generative machine learning model 318 (e.g., an array of tokens) .
[0077] In some aspects, the generative machine learning model 318 is configured to use the embeddings during inference to begin inference operation based on the prompt 302. In some aspects, the probabilities from the classifier 312 can be used by the generative machine learning model 318 to activate at least one adapter based on the probability associated with that adapter. In some aspects, because the adapters are tuned independently based on clustered data, the adapters provide a stronger response based on the identification of features that more accurately represent that different classification.
[0078] The generative machine learning model 318 may be configured to synthesize the response 304 based on the probabilities provided by the classifier 312 and the generative machine learning model 318.
[0079] In some cases, the generative machine learning model 318 may learn a large and rich semantic and / or syntactic knowledge and this knowledge may be transferred across different tasks, for example using Low-Rank Adapters (LoRAs) , or other types of adapters. A LoRA may be plugged into various layers of a base generative machine learning model 318 to fine tune the base generative machine learning model 318 for specific tasks.
[0080] FIG. 4 is a block diagram illustrating an example of a system 400 including a base model 410 and various adapters 420a-420n, in accordance with aspects of the disclosure. In some aspects, the adapters 420a-420n can include LoRAs or other types of adapters.
[0081] The base model 410 and / or the adapters 420a-n may be adjusted or calibrated (e.g., quantized) to generate one or more activation encodings, which represent how parameters of the model (e.g., tensors) are quantized. For instance, an activation encoding refers to the quantization level for a particular activation (e.g., the quantization step size or grid used for the activation) . As described herein, quantization refers to a reduction in precision of values or numbers representing parameters (e.g., weights) or activations. For example, the values or numbers can be quantized by converting the values or numbers from floating point values to integer values, or first floating-point values with a first precision to second floating point values with a second precision.
[0082] Activation encodings may be categorized as base activation encodings (applicable to layers of the base model 410) or adapter activation encodings (applicable to one or more of the adapters 420a-n) . Examples of base activation encodings include 417, 415, and 412. Examples of adapter activation encodings include 431a-n, 429a-n, 427a-n, 414, 425a-n, 423a-n, 421a-n, and 411.
[0083] In some aspects, one or more of the adapters 420a-n can include a LoRA. A LoRA can include trainable rank decomposition matrices. Use of LoRAs to fine-tune the base model 410 can involve freezing the base model weights (or base weights) and combining outputs of the trainable rank decomposition matrices with outputs of one or more layers of the base model 410 to then tune parameters of the LoRA. A LoRA can include two matrices, referred to as matrix A and matrix B. As shown, each adapter 420a-n includes matrix A (with dimensions d x r) , a scalar value denoted as alpha (α) , and matrix B (with dimensions r x m) . Rank (r) is proportional to a number of trainable parameters in the adapter model. Therefore, a higher rank implies a greater number of trainable parameters in the adapter model, whereas lower rank implies fewer trainable parameters. In general, the low rank matrices A and B include a rank (r) having a size that is much smaller than the size of d and m (r<<d, m) . Alpha (α) is a scaling factor that can control how much influence the adapter will have on a combined output resulting from combining an output of a layer of the base model 410 (e.g., the linear layer 416 and / or the linear layer 413) with an output of the adapter. For instance, a higher alpha (α) value can result in the adapter having more influence on the combined output, while a lower alpha (α) value can result in the adapter having less influence on the combined output. Adjustment of “alpha” can balance fitting the data against overfitting. The dimension of the original weight is represented by d.
[0084] The base model 410 includes two linear layers 413 and 416, but additional layers are possible. Each adapter 420a-n includes a capability of scaling and / or adjusting parameters or weights based on training, such as parameters of the matrices A, B and alpha (α) . Various inputs and outputs of the linear layers 413 and 416 are shared between the base model 410 and adapters 420a-n. Similarly, outputs from each of the adapters 420a-n are shared with the base model 410 and ultimately combined into inputs to various linear layers.
[0085] In the example depicted in FIG. 4, base activation encoding 417 is provided as input to base model 410, specifically linear layer 416, and to adapter 420a. Linear layer 416 processes base activation encoding 417, outputting base activation encoding 415. The adapter multiplies the base activation encoding 417 with matrix A 432a, resulting in the adapter outputting adapter activation encoding 431a. Adapter activation encoding 431a is scaled by scaling block 430a, which generates adapter activation encoding 429a. The adapter then multiplies the adapter activation encoding 429a by matrix B 428a to generate and output adapter activation encoding 427a. Adapter activation encoding 429a is passed back to base model 410, where adapter activation encoding 429a is combined with (e.g., added to, concatenated with, etc. ) the base activation encoding 415, resulting in adapter activation encoding 414.
[0086] Similarly, adapter activation encoding 414 is passed both as an input to linear layer 413 and to adapter 420a. Linear layer 413 processes the input, outputting base activation encoding 412. Separately, matrix A 426a is multiplied with adapter activation encoding 414, resulting in adapter activation encoding 425a. Adapter activation encoding 425a is scaled by scaling 424a, which results in adapter activation encoding 423a. Adapter activation encoding 423a is multiplied with matrix B 422a, creating adapter activation encoding 421a. Adapter activation encoding 421a is passed back to base model 410, where adapter activation encoding 421a is added to base encoding 412, resulting in adapter activation encoding 411. Different activation encodings may be generated using the techniques described herein.
[0087] FIG. 5 is a block diagram illustration an example of knowledge distillation 500, in accordance with aspects of the present disclosure. In knowledge distillation 500, knowledge from a pre-trained teacher ML model 502 (e.g., target ML model) may be used to train a student ML model 504 (e.g., draft ML model) to generate similar predictions (e.g., aligning the ML models) as the teacher ML model 502 given the same input. In some cases, the teacher ML model 502 may be a relatively larger and / or more computationally expensive ML model as compared to the student ML model 504. For example, the teacher ML model 502 may include more layers as compared to the student ML model 504. As the student ML model 504 may be a more lightweight ML model, the student ML model 504 may have a lower representational power as compared to the teacher ML model 502 and the student ML model 504 may learn more relevant information quicker using predictions (e.g., output distributions) of the teacher ML model 502 as compared to the ground truth labels alone.
[0088] To train the student ML model 504, training data 506 may be passed into both the teacher ML model 502 and the student ML model 504. A student prediction 510 of the student ML model may be compared 514 against a teacher prediction 512 (e.g., output distribution) of the teacher ML model 502 and a loss may be determined based on a difference between the student prediction 510 and the teacher prediction 512 and back-propagated through the student ML model 504. In some cases, the ground truth labels 516 may also be used, for example to calculate the loss for back-propagation. In some cases, knowledge distillation based training may be used along with speculative decoding based inference to help speed up certain AI tasks related to LLMs, such as chat, summarization, translation, etc.
[0089] As part of a training process, parameters affecting the functioning of the artificial neurons and layers may be adjusted. For example, backpropagation techniques may be used to train an ML by iteratively adjusting weights or biases of certain artificial neurons associated with errors between a predicted output of the model and a desired output that may be known or otherwise deemed acceptable. Backpropagation may include a forward pass, a loss function, a backward pass, and a parameter update that may be performed in training iteration. The process may be repeated for a certain number of iterations for each set of training data until the weights of the artificial neurons / layers are adequately tuned.
[0090] Backpropagation techniques associated with a loss function may measure how well a model is able to predict a desired output for a given input. An optimization algorithm may be used during a training process to adjust weights and biases as needed to reduce or minimize the loss function which should improve the performance of the model. There are a variety of optimization algorithms that may be used along with backpropagation techniques or other training techniques. Some initial examples include a gradient descent based optimization algorithm and a stochastic gradient descent based optimization algorithm. A stochastic gradient descent technique may be used to adjust weights / biases in order to minimize or otherwise reduce a loss function. A mini-batch gradient descent technique, which is a variant of gradient descent, may involve updating weights / biases using a small batch of training data rather than the entire dataset. A momentum technique may accelerate an optimization process by adding a momentum term to update or otherwise affect certain weights / biases.
[0091] In some cases, a generalized Kullback-Leibler divergence (GKLD) loss may be used as a loss function for knowledge distillation. In some cases, GKLD may be a generalized form of a Kullback-Leibler divergence (KLD) loss and include a KLD function and a reversed KLD (RKLD) function. The KLD function, where KL ( (P||Q) , may be expressed as where P represents a teacher model probability distribution of σ (logitst) , and where Q represents student ML model 642 probability distribution σ (logitss) , and where σ () represents a softmax operation. In some cases, the KLD function may be mode-seeking and focus more on central part of a distribution while reducing sensitivity to differences near tail ends of a distribution. The reverse KLD function may be expressed as The reverse KLD function may reduce sensitivity to differences near a center of the distribution and focus more on tail differences and / or outliers. The GKLD may then integrate both the KLD function and reverse KLD (RKLD) function such that GKLDβ=βKLD+ (1-β) RKLD, where β is a divergence metric hyperparameter such that where β>1, differences between a tail of the distribution is emphasized to help take into account outliers, where β<1 reduces sensitivity to tail differences and focuses more on central part of a distribution (e.g., ) , and where β=1 , the generalized GKLD converges to the KLD (e.g., ) . The hyperparameter β allows the GKLD to be tuned to combine the KLD and reverse KLD functions into a single loss for KD training.
[0092] As indicated above, QAT may be a technique where a ML model, such as generative machine learning model 318, is trained taking into account for quantization. For example, the ML model can be trained while simulating effects of actual quantization of weights and / or activations of the machine learning model during training. As used herein, a trained (e.g., post-QAT) ML model, before quantization, may be referred to as a base ML model, and a ML model that has been quantized may be referred to as a quantized ML model. In some cases, during fine tuning, weights of the quantized ML model may further be updated. In some cases, a quantization scale and / or offset (e.g., range) for activations and / or weights may also be learned as a part of QAT. The quantization scale may refer to a number the activations and / or weights are multiplied by for quantization. In some cases, during QAT, quantization loss (e.g., noise introduced by the quantization) may dominant the training gradient (e.g., slope of gradient in a graph toward a lower error) , making optimization of the quantized ML model for a task difficult. Additionally, sparse quantization activations and weights may introduce random jitter, making convergence for the quantized ML model to optimized weights difficult. In some cases, while QAT can improve the performance of a quantized ML model, there can still be a significant gap between the quantized ML as the base ML model.
[0093] In some cases, to improve accuracy and / or performance for quantized ML models, it may be useful to introduce a LoRA trained for accuracy to help mitigate quantization losses of a quantized ML model. As indicated above, LoRAs may have a relatively (e.g., as compared to the quantized ML model) , lower rank as they include fewer trainable parameters. As a LoRA has a smaller number of parameters, larger bit width (e.g., number of bits per parameter) may not introduce as large of an overhead cost as compared to a base ML model. In some cases, the LoRA may have a higher bit width as compared to the quantized ML model. For example, a quantized ML model with 4 bit parameters and approximately 3 billion parameters may be used with a LoRA adapter with 8 bit parameters. Such a LoRA may be sized in the tens of megabytes as compared to hundreds of megabytes of a base model with 16-bit parameters. In some cases, the LoRA adapter may be fused back to the base ML model or kept as an independent branch attached to the base model. In some cases, the LoRA adapter in an independent branch may be visible in a computational graph of the ML model, and / or a scale of the LoRA adapter can be adjusted.
[0094] As indicated above, the LoRA may be trained to minimize quantization loss (e.g., quantization error) and task loss (e.g., degradation in how well the quantized ML model perform a task as compared to the base ML model) . For example, a LoRA based QAT framework may be used by combining multiple loss functions from adapter training to help improve QAT accuracy. In some cases, a combined loss function may be used as a part of the knowledge distillation. In some cases, label smoothing may also be applied to a mean cross entropy loss function. Additionally, on policy sampling may be used to guide the loss function. In some cases, the on-policy sampling may include on policy group sampling and / or on policy rejection sampling.
[0095] FIG. 6 is a block diagram illustrating an architecture for a technique for using policy sampling to guide losses for training adapters 600, in accordance with aspects of the present disclosure. FIG. 6 includes a teacher ML model 640 including a base ML model 602, which may include one or more base adapters 604. The base ML model 602 may generate teacher logits 606. Logits may be raw, unnormalized scores (e.g., predictions) that may be output by a ML model layer before an activation function, such as softmax, is applied. Similarly, a student ML model 642 may include a quantized ML model 608 along with a training adapter 610 and generate student logits 612. The base ML model 602, base adapter, and quantized ML model may be frozen 620 (e.g., weights remain unchanged) , while the training adapter 610 may have changeable weights during a tuning 622 / training process. In some cases, the quantized ML model 608 may be a quantized version of the base ML model 602.
[0096] To train the training adapter 610, the student logits 612 may be compared with the teacher logits 606 to generate distribution loss (e.g., first loss) , such as a GKLD loss 614. A distribution loss function may measure an error between an expected distribution of values (e.g., from a ground truth or teacher logits 606) and a predicted distribution of values (e.g., from the student logits 612) . In some cases, as the GKLD loss 614 compares the student logits 612 to the teacher logits 606 to match a distribution of values of the student logits 612 to the teacher logits 606. The GLKD loss may represent a classical view of QAT training where the quantized ML model 608 represents a perturbation of the base ML model 602 and the goal of the training is to restore the output of the base ML model 602 without consideration of a particular task.
[0097] Another classical approach to QAT training may view the quantized ML model 608 as a weakened version of the base ML model 602 for a given downstream task with an aim to enhance the performance of the quantized ML model 608 for the downstream task. In such cases, the student logits 612 may be compared to a labels dataset 616 to determine a task loss (e.g., second loss) , such as a Mean Cross-Entropy (MCE) loss 618. A task loss may measure how well a ML model performs a particular task by determining an error as between a target value (e.g., from a label, ground truth, etc. ) a predicted value (e.g., from the student logits 612) . In some cases, the labels dataset 616 may include labels for the training data being used to train the training adapter 610 for the downstream task.
[0098] In some cases, applying the classical approaches individually may be incomplete and may not restore the quantization loss. In some cases, a combined loss function may be used to more fully encompass the quantization loss. This combined loss function may combine a distribution loss with a task loss, such as GKLD loss 614 and MCE loss 618, respectively, into a combined loss function. The combined loss function may help minimize the divergence between the student logits 612 and the teacher logits 606 via the GKLD loss 614 while also minimizing a cross-entropy between the student logits 612 and the labels dataset 616 using the MCE loss 618. This combined loss function (LossGKD-QAT) combining the GKLD loss 614 and MCE loss 618 may be expressed as LossGKD-QAT=αGKLD+ (1-α) MCE , where α represents a weighting factor as between the GKLD loss 614 and MCE loss 618. In some cases, α may be used as a hyperparameter that allows the combined loss function to be tuned to emphasize the distribution loss or the task loss.
[0099] Cross-entropy losses, such as an MCE loss, may often be used as a loss function for classification tasks where there is a ground truth label that a prediction from a ML model in training can be compared with. In language based tasks, such as for a large language model (LLM) , there may be no absolute ground truth when modeling language. Rather the LLM may probabilistically predict tokens based on an input prompt. In some cases, labels, such as for labels in the labels dataset 616, may be encoded using one hot encoding. For one hot encoding, a label may be represented by a vector with one parameter (e.g., a “correct” token) set to a value (e.g., true, 1, etc. ) and all of the other parameters (e.g., other tokens) set to another value (e.g., false, 0, etc. ) . However, for language tasks, one hot encoding may cause a ML model to be overconfident in predictions. It may be useful to incorporate label smoothing as a part of training the training adapter 610 to better fit cross-entropy losses for probabilistic modeling.
[0100] In some cases, a smoothing MCE loss may be used in place of the MCE loss 618 to include label smoothing for training the training adapter 610. The smoothing MCE loss may include a one hot vector y (e.g., [0, 1, 0, …0] ) and a second vector z, such as an equal hot vector where each vector value (e.g., token) has a same value (e.g., [1 / n, 1 / n, …, 1 / n] , where n is the vocabulary size (e.g., number of tokens) ) . The smoothing MCE loss may be determined as MCEε=-∑ ( ( (1-ε) y+εz)log(σ (logitss) ) ) , where ε represents a weighting factor that may be used as a hyperparameter to tune how much emphasis to apply to the equal hot vector and / or one hot vector.
[0101] In some cases, the MCE loss may be applied certain portions of a vector. For example, in some cases an LLM, such as the base ML model 602 and / or quantized ML model 608 may output a vector that includes both the input tokens, output tokens, and possibly a set of padding tokens. In some cases, a mask may be applied to remove / ignore tokens other than the output tokens (e.g., the input tokens and padding tokens) for determining the MCE loss. In some cases, masking may be applied to the smoothing MCE loss.
[0102] In some cases, during training of a training adapter 610, a loss, such as the GKLD loss 614 may be determined based on the ground truth, as expressed by the teacher logits 606 to guide the output from the quantized ML model 608 and training adapter 610 towards the ground truth label (e.g., token) of the teacher logits 606 (which represents the ground truth that may have been used to train the base ML model 602) . However, if a gap or distance between what is being output by the quantized ML model 608 / training adapter 610 and the label becomes too large, the training may result in divergence from the ground truth or a convergence to a local optima.
[0103] To avoid this potential divergence or local optima, on-policy sampling may be used instead of off-policy sampling. For off-policy sampling, losses may be determined for predicted values (e.g., tokens) as they are generated (e.g., token-by-token) . On-policy sampling may be used to improve divergency as between the student logits 612 and a ground truth, as expressed by the teacher logits 606. On-policy sampling may allow the student ML model 642 (e.g., quantized ML model / training adapter 610) being trained to generate multiple predicted values (e.g., a sequence) and a loss may be determined across the multiple predicted values (e.g., tokens of the sequence) as a whole in comparison to a ground truth sequence. As an example, for an event extraction text where an input may be “Mark: Let’s have pizza this Saturday night with William. Alice: Okay, ” the student ML model 642 may generate an on-policy sequence of [ { ‘time’ : ‘Saturday night’ , ‘title have pizza been cooked or not? Alice: Yes} ] . This on-policy sequence may be compared, as a whole, to a ground truth sequence of [ { ‘time’ : ‘Saturday night’ , ‘title’ : ‘have pizza with William’ } ] to determine a loss using, for example, the GKLD loss 614.
[0104] In some cases, the student logits 612 may be converted to tokens via, for example, a softmax operation 630 (σ) , which may select a predicted value with a highest probability as the token. In some cases, the sequences generated by the student ML model 642 may be stored in an on-policy labels store 632. In some cases, the GKLD loss 614 for a sequence may be expressed as where and where
[0105] In some cases, a total combined loss function including mean cross entropy and GKLD (LossGKD-QAT) may be expressed as In some cases, hyperparameter settings may be used to configure the total combined loss function. For example, off-policy sampling may be performed based on hyperparameter settings λ=0.0, α =0.7, β =0.5, ε =0.1, on-policy sampling may be performed based on hyperparameter settings λ=0.5, α =0.7, β =0.5, ε =0.1, and QAT training may be performed based on hyperparameter settings λ=0.0, α=0.0, β=0.0, ε=0.0.
[0106] In some cases, group sampling may be used for on-policy sampling. For example, on-policy sampling can be relatively slow as the student ML model 642 may perform multiple inference rounds to generate a single sequence, thus reducing a rate at which losses may be generated to provide feedback for training the student ML model 642. To accelerate on-policy sampling, group sampling may be used. In group sampling, the student ML model 642 may be configured to generate a top K probable sequences. For example, as discussed above, a softmax operation 630 may be used to select a most probable sequence and this may be adjusted to provide the top K sequences. In some cases, obtaining the top K sequences may be performed almost as quickly as generating a single sequence. The loss, such as GKLD loss 614, may then be performed for each to the top K sequences.
[0107] In some cases, quantized ML models, such as quantized ML model 608, tend to be less confident in predicting a stop signal for a sequence and thus tend to generate longer sequences. In some cases, spending too much time on such sequences may be a factor that slows down a training process, for example, for a training adapter 610. In some cases, it may be useful to apply a heuristic to determine whether a sequence is likely to be meaningful for training based on a length of the sequence. Longer sequences are more likely to be linked with less confident predictions from the student ML model 642 and may be rejected (e.g., not used to generate a loss) . As an example of such a heuristic, where group sampling is used to generate multiple sequences, and sequences may be rejected based on a length of those sequences. For example, those sequences that are longer (e.g., contain more tokens) than a median number of tokens for sequences of the multiple sequences may be rejected. Rejecting sequences based on the median number of tokens from multiple sequences may result in approximately half of the sequences of the multiple sequences being rejected, allowing an amount of time for the loss computation to be approximately halved.
[0108] FIG. 7 is a flow diagram illustrating a process 700 for training a machine learning model, in accordance with aspects of the present disclosure. The process 700 may be performed by a computing device (or apparatus) (e.g., system 100 of FIG. 1, computing device architecture 1400 of FIG. 14) or a component (e.g., a chipset, codec, CPU 102, GPU 104, DSP 106, NPU 108 of FIG. 1, processor 1410 of FIG. 14, etc. ) of the computing device. The computing device may be a mobile device (e.g., a mobile phone) , a network-connected wearable such as a watch, an extended reality (XR) device such as a virtual reality (VR) device or augmented reality (AR) device, a vehicle or component or system of a vehicle, or other type of computing device. The operations of the process 700 may be implemented as software components that are executed and run on one or more processors.
[0109] At block 702, the computing device (or component thereof) may generate a first loss (e.g., GKLD loss 614 of FIG. 6) based on teacher features from a teacher ML model (teacher ML model 640 of FIG. 6) and student features from a student ML model (e.g., student ML model 642 of FIG. 6) . In some cases, the first loss comprises a distribution loss and the second loss comprises a task loss. In some examples, the distribution loss comprises a generalized Kullback-Leibler divergence (GKLD) loss. In some examples, the task loss comprises a Mean Cross-Entropy (MCE) loss. In some cases, the task loss comprises a smoothing Mean Cross-Entropy (MCE) loss. In some examples, the computing device (or component thereof) may generate the smoothing MCE loss based on a one hot vector and an equal hot vector. In some cases, the first loss is generated based on logits obtained using on-policy sampling. In some examples, the on-policy sampling generates multiple sequences based on a number of top probable sequences. For example, On-policy sampling may allow the student ML model (e.g., quantized ML model / training adapter) being trained to generate multiple predicted values (e.g., a sequence) and a loss may be determined across the multiple predicted values (e.g., tokens of the sequence) as a whole in comparison to a ground truth sequence. In some cases, the computing device (or component thereof) may reject a sequence, of the multiple sequences, based on a length of the sequence. For example, it may be useful to apply a heuristic to determine whether a sequence is likely to be meaningful for training based on a length of the sequence where longer sequences are more likely to be linked with less confident predictions.
[0110] At block 704, the computing device (or component thereof) may generate a second loss (e.g., MCE loss 618 of FIG. 6) based on the student features and a label (e.g., from labels dataset 616 of FIG. 6) . In some cases, the teacher features include teacher logits (e.g., teacher logits 606 of FIG. 6) from the teacher ML model, and wherein the student features include student logits (e.g., student logits 612 of FIG. 6) from the student ML model.
[0111] At block 706, the computing device (or component thereof) may combine the first loss and the second loss to generate a combined loss. In some cases, a combined loss function may be used to more fully encompass the quantization loss. This combined loss function may combine a distribution loss with a task loss, such as GKLD loss and MCE loss, respectively, into a combined loss function.
[0112] At block 708, the computing device (or component thereof) may train the student ML model based on the combined loss. In some cases, the computing device (or component thereof) may train the student ML model based on the combined loss by training an adapter (e.g., training adapter 610 of FIG. 6) of the student ML model based on the combined loss.
[0113] In some examples, the techniques or processes described herein may be performed by a computing device, an apparatus, and / or any other computing device. In some cases, the computing device or apparatus may include a processor, microprocessor, microcomputer, or other component of a device that is configured to carry out the steps of processes described herein. In some examples, the computing device or apparatus may include a camera configured to capture video data (e.g., a video sequence) including video frames. For example, the computing device may include a camera device, which may or may not include a video codec. As another example, the computing device may include a mobile device with a camera (e.g., a camera device such as a digital camera, an IP camera or the like, a mobile phone or tablet including a camera, or other type of device with a camera) . In some cases, the computing device may include a display for displaying images. In some examples, a camera or other capture device that captures the video data is separate from the computing device, in which case the computing device receives the captured video data. The computing device may further include a network interface, transceiver, and / or transmitter configured to communicate the video data. The network interface, transceiver, and / or transmitter may be configured to communicate Internet Protocol (IP) based data or other network data.
[0114] The processes described herein can be implemented in hardware, computer instructions, or a combination thereof. In the context of computer instructions, the operations represent computer-executable instructions stored on one or more computer-readable storage media that, when executed by one or more processors, perform the recited operations. Generally, computer-executable instructions include routines, programs, objects, components, data structures, and the like that perform particular functions or implement particular data types. The order in which the operations are described is not intended to be construed as a limitation, and any number of the described operations can be combined in any order and / or in parallel to implement the processes.
[0115] In some cases, the devices or apparatuses configured to perform the operations of the process 700 and / or other processes described herein may include a processor, microprocessor, micro-computer, or other component of a device that is configured to carry out the steps of the process 700 and / or other process. In some examples, such devices or apparatuses may include one or more sensors configured to capture image data and / or other sensor measurements. In some examples, such computing device or apparatus may include one or more sensors and / or a camera configured to capture one or more images or videos. In some cases, such device or apparatus may include a display for displaying images. In some examples, the one or more sensors and / or camera are separate from the device or apparatus, in which case the device or apparatus receives the sensed data. Such device or apparatus may further include a network interface configured to communicate data.
[0116] The components of the device or apparatus configured to carry out one or more operations of the process 700 and / or other processes described herein can be implemented in circuitry. For example, the components can include and / or can be implemented using electronic circuits or other electronic hardware, which can include one or more programmable electronic circuits (e.g., microprocessors, graphics processing units (GPUs) , digital signal processors (DSPs) , central processing units (CPUs) , and / or other suitable electronic circuits) , and / or can include and / or be implemented using computer software, firmware, or any combination thereof, to perform the various operations described herein. The computing device may further include a display (as an example of the output device or in addition to the output device) , a network interface configured to communicate and / or receive the data, any combination thereof, and / or other component (s) . The network interface may be configured to communicate and / or receive Internet Protocol (IP) based data or other type of data.
[0117] The process 700 is illustrated as a logical flow diagram, the operations of which represent sequences of operations that can be implemented in hardware, computer instructions, or a combination thereof. In the context of computer instructions, the operations represent computer-executable instructions stored on one or more computer-readable storage media that, when executed by one or more processors, perform the recited operations. Generally, computer-executable instructions include routines, programs, objects, components, data structures, and the like that perform particular functions or implement particular data types. The order in which the operations are described is not intended to be construed as a limitation, and any number of the described operations can be combined in any order and / or in parallel to implement the processes.
[0118] Additionally, the processes described herein (e.g., the process 700 and / or other processes) may be performed under the control of one or more computer systems configured with executable instructions and may be implemented as code (e.g., executable instructions, one or more computer programs, or one or more applications) executing collectively on one or more processors, by hardware, or combinations thereof. As noted above, the code may be stored on a computer-readable or machine-readable storage medium, for example, in the form of a computer program including a plurality of instructions executable by one or more processors. The computer-readable or machine-readable storage medium may be non-transitory.
[0119] Additionally, the processes described herein may be performed under the control of one or more computer systems configured with executable instructions and may be implemented as code (e.g., executable instructions, one or more computer programs, or one or more applications) executing collectively on one or more processors, by hardware, or combinations thereof. As noted above, the code may be stored on a computer-readable or machine-readable storage medium, for example, in the form of a computer program comprising a plurality of instructions executable by one or more processors. The computer-readable or machine-readable storage medium may be non-transitory.
[0120] In some examples, the techniques or processes described herein may be performed by a computing device or an apparatus, and / or any other computing device. In some cases, the computing device or apparatus may include a processor, microprocessor, microcomputer, or other component of a device that is configured to carry out the steps of processes described herein. In some examples, the computing device or apparatus may include a camera configured to capture video data (e.g., a video sequence) including video frames. For example, the computing device may include a camera device, which may or may not include a video codec. As another example, the computing device may include a mobile device with a camera (e.g., a camera device such as a digital camera, an IP camera or the like, a mobile phone or tablet including a camera, or other type of device with a camera) . In some cases, the computing device may include a display for displaying images. In some examples, a camera or other capture device that captures the video data is separate from the computing device, in which case the computing device receives the captured video data. The computing device may further include a network interface, transceiver, and / or transmitter configured to communicate the video data. The network interface, transceiver, and / or transmitter may be configured to communicate Internet Protocol (IP) based data or other network data.
[0121] The processes described herein can be implemented in hardware, computer instructions, or a combination thereof. In the context of computer instructions, the operations represent computer-executable instructions stored on one or more computer-readable storage media that, when executed by one or more processors, perform the recited operations. Generally, computer-executable instructions include routines, programs, objects, components, data structures, and the like that perform particular functions or implement particular data types. The order in which the operations are described is not intended to be construed as a limitation, and any number of the described operations can be combined in any order and / or in parallel to implement the processes.
[0122] Additionally, the processes described herein may be performed under the control of one or more computer systems configured with executable instructions and may be implemented as code (e.g., executable instructions, one or more computer programs, or one or more applications) executing collectively on one or more processors, by hardware, or combinations thereof. As noted above, the code may be stored on a computer-readable or machine-readable storage medium, for example, in the form of a computer program comprising a plurality of instructions executable by one or more processors. The computer-readable or machine-readable storage medium may be non-transitory.
[0123] Machine learning (ML) can be considered a subset of artificial intelligence (AI) . ML systems can include algorithms and statistical models that computer systems can use to perform various tasks by relying on patterns and inference, without the use of explicit instructions. One example of an ML system is a neural network (also referred to as an artificial neural network) , which may include an interconnected group of artificial neurons (e.g., neuron models) . Neural networks may be used for various applications and / or devices, such as image and / or video coding, image analysis and / or computer vision applications, Internet Protocol (IP) cameras, Internet of Things (IoT) devices, autonomous vehicles, service robots, among others.
[0124] Individual nodes in a neural network may emulate biological neurons by taking input data and performing simple operations on the data. The results of the simple operations performed on the input data are selectively passed on to other neurons. Weight values are associated with each vector and node in the network, and these values constrain how input data is related to output data. For example, the input data of each node may be multiplied by a corresponding weight value, and the products may be summed. The sum of the products may be adjusted by an optional bias, and an activation function may be applied to the result, yielding the node’s output signal or “output activation” (sometimes referred to as a feature map or an activation map) . The weight values may initially be determined by an iterative flow of training data through the network (e.g., weight values are established during a training phase in which the network learns how to identify particular classes by their typical input data characteristics) .
[0125] Different types of neural networks exist, such as convolutional neural networks (CNNs) , recurrent neural networks (RNNs) , generative adversarial networks (GANs) , multilayer perceptron (MLP) neural networks, transformer neural networks, diffusion-based neural networks, among others. For instance, convolutional neural networks (CNNs) are a type of feed-forward artificial neural network. Convolutional neural networks may include collections of artificial neurons that each have a receptive field (e.g., a spatially localized region of an input space) and that collectively tile an input space. RNNs work on the principle of saving the output of a layer and feeding this output back to the input to help in predicting an outcome of the layer. A GAN is a form of generative neural network that can learn patterns in input data so that the neural network model can generate new synthetic outputs that reasonably could have been from the original dataset. A GAN can include two neural networks that operate together, including a generative neural network that generates a synthesized output and a discriminative neural network that evaluates the output for authenticity. In MLP neural networks, data may be fed into an input layer, and one or more hidden layers provide levels of abstraction to the data. Predictions may then be made on an output layer based on the abstracted data.
[0126] Deep learning (DL) is one example of a machine learning technique and can be considered a subset of ML. Many DL approaches are based on a neural network, such as an RNN or a CNN, and utilize multiple layers. The use of multiple layers in deep neural networks can permit progressively higher-level features to be extracted from a given input of raw data. For example, the output of a first layer of artificial neurons becomes an input to a second layer of artificial neurons, the output of a second layer of artificial neurons becomes an input to a third layer of artificial neurons, and so on. Layers that are located between the input and output of the overall deep neural network are often referred to as hidden layers. The hidden layers learn (e.g., are trained) to transform an intermediate input from a preceding layer into a slightly more abstract and composite representation that can be provided to a subsequent layer, until a final or desired representation is obtained as the final output of the deep neural network.
[0127] As noted above, a neural network is an example of a machine learning system, and can include an input layer, one or more hidden layers, and an output layer. Data is provided from input nodes of the input layer, processing is performed by hidden nodes of the one or more hidden layers, and an output is produced through output nodes of the output layer. Deep learning networks typically include multiple hidden layers. Each layer of the neural network can include feature maps or activation maps that can include artificial neurons (or nodes) . A feature map can include a filter, a kernel, or the like. The nodes can include one or more weights used to indicate an importance of the nodes of one or more of the layers. In some cases, a deep learning network can have a series of many hidden layers, with early layers being used to determine simple and low-level characteristics of an input, and later layers building up a hierarchy of more complex and abstract characteristics.
[0128] A deep learning architecture may learn a hierarchy of features. If presented with visual data, for example, the first layer may learn to recognize relatively simple features, such as edges, in the input stream. In another example, if presented with auditory data, the first layer may learn to recognize spectral power in specific frequencies. The second layer, taking the output of the first layer as input, may learn to recognize combinations of features, such as simple shapes for visual data or combinations of sounds for auditory data. For instance, higher layers may learn to represent complex shapes in visual data or words in auditory data. Still higher layers may learn to recognize common visual objects or spoken phrases.
[0129] Deep learning architectures may perform especially well when applied to problems that have a natural hierarchical structure. For example, the classification of motorized vehicles may benefit from first learning to recognize wheels, windshields, and other features. These features may be combined at higher layers in different ways to recognize cars, trucks, and airplanes.
[0130] Neural networks may be designed with a variety of connectivity patterns. In feed-forward networks, information is passed from lower to higher layers, with each neuron in a given layer communicating to neurons in higher layers. A hierarchical representation may be built up in successive layers of a feed-forward network, as described above. Neural networks may also have recurrent or feedback (also called top-down) connections. In a recurrent connection, the output from a neuron in a given layer may be communicated to another neuron in the same layer. A recurrent architecture may be helpful in recognizing patterns that span more than one of the input data chunks that are delivered to the neural network in a sequence. A connection from a neuron in a given layer to a neuron in a lower layer is called a feedback (or top-down) connection. A network with many feedback connections may be helpful when the recognition of a high-level concept may aid in discriminating the particular low-level features of an input.
[0131] FIG. 8 provides two sets of images 800 that show the forward diffusion process (which is fixed) and the reverse diffusion process (which is learned) of a diffusion model. As shown in the forward diffusion process of FIG. 8, noise 803 is gradually added to a first set of images 802 at different time steps for a total of T time steps (e.g., making up a Markov chain) , producing a sequence of noisy samples X1 through XT.
[0132] Diffusion models from a training perspective will take an image and will slowly add noise to the image to destroy the information in the image. In some aspects, the noise 803 is Gaussian noise. Each time step can correspond to each consecutive image of the first set of images 802 shown in FIG. 8. The initial image X0 of FIG. 8 is of a cat. Addition of the noise 803 to each image (corresponding to noisy samples X1 to XT) results in gradual diffusion of the pixels in each image until the final image (corresponding to sample XT) essentially matches the noise distribution. For example, by adding the noise, each data sample X1 through XT gradually loses its distinguishable features as the time step becomes larger, eventually resulting in the final sample XT being equivalent to the target noise distribution, for instance a unit variance zero-Gaussian
[0133] The second set of images 804 shows the reverse diffusion process in which XT is the starting point with a noisy image (e.g., one that has Gaussian noise) . The diffusion model can be trained to reverse the diffusion process (e.g., by training a model pθ (xt-1|xt) ) to generate new data. In some aspects, a diffusion model can be trained by finding the reverse Markov transitions that maximize the likelihood of the training data. By traversing backwards along the chain of time steps, the diffusion model can generate the new data. For example, as shown in FIG. 8, the reverse diffusion process proceeds to generate X0 as the image of a vase. In other cases, the input data and output data can vary based on the task for which the diffusion model is trained.
[0134] As noted above, the diffusion model is trained to be able to denoise or recover the original image X0 in an incremental process as shown in the second set of images 804. In some aspects, the neural network of the diffusion model can be trained to recover Xt given Xt-1, such as provided in the below example equation:
[0135] A diffusion kernel can be defined as: Define
[0136] Sampling can be defined as follows: where
[0137] In some cases, the βt values schedule (also referred to as a noise schedule) is designed such that and
[0138] The diffusion model runs in an iterative manner to incrementally generate the input image X0. In one example, the model may have twenty steps. However, in other examples, the number of steps can vary.
[0139] FIG. 9 is a diagram 900 illustrating how diffusion data is distributed from initial data to noise using a diffusion model in the forward diffusion direction, in accordance with some aspects. Note that the initial data q (X0) is detailed in the initial stage of the diffusion process. An illustrative example of the data q (X0) is the initial image of the vase shown in FIG. 9. As the diffusion model iterates and iteratively adds sampled noise to the data from t = 0 to t = T, as shown in FIG. 9, the data becomes nosier and may ultimately result in pure noise (e.g., at q (XT) ) . The example of FIG. 9 illustrates the progression of the data and how it becomes diffused with noise in the forward diffusion process.
[0140] In some aspects, the diffused data distribution (e.g., as shown in FIG. 9) can be as follows: q (xt) =∫q (x0, xt) dx0= ∫q (x0) q (xt|x0) dx0.
[0141] In the above equation, q (xt) represents the diffused data distribution, q (x0, xt) represents the joint distribution, q (x0) represents the input data distribution, and q (xt|x0) is the diffusion kernel. In this regard, the model can sample xt ~ q (xt) by first sampling and then sampling xt ~q (xt|x0) (which may be referred to as ancestral sampling) . The diffusion kernel takes the input and returns a vector or other data structure as output.
[0142] The following is a summary of a training algorithm and a sampling algorithm for a diffusion model. A training algorithm can include the following steps: 1: repeat 2: x0 ~q (x0) 3: t ~Uniform ( {1, ..., T} ) 4: 5: Take gradient descent step on 6: until converged
[0143] A sampling algorithm can include the following steps: 1: 2: for t= T, ..., 1 do 3: 4: 5: end for 6: return x0
[0144] FIG. 10 is a diagram illustrating a U-Net architecture 1000 for a diffusion model, in accordance with some aspects. The initial image 1002 (e.g., of a cat) is provided to the U-Net architecture 1000 which includes a series of residual networks (ResNet) blocks and self-attention layers to represent the network εθ (xt, t) . The U-Net architecture 1000 also includes fully connected layers 1008. In some cases, time representation 1010 can be sinusoidal positional embeddings or random Fourier features. Noisy output 1006 from the forward diffusion process is also shown.
[0145] The U-Net architecture 1000 includes a contracting path 1004 and an expansive path 1005 as shown in FIG. 10, which gives it the U-shaped architecture. The contracting path 1004 can be a convolutional network that includes repeated convolutional layers (that apply convolutional operations) , each followed by a rectified linear unit (ReLU) and a max pooling operation. When images are being processed (e.g., the image 1002) during the contracting path 1004, the spatial information of the image 1002 is reduced as features are generated. The expansive path 1005 combines the features and spatial information through a sequence of up-convolutions and concatenations with high-resolution features from the contracting path 1004. Some of the layers can be self-attention layers, which leverage global interactions between semantic features at the end of the encoder to explicitly model full contextual information.
[0146] FIG. 11 is an illustrative example of a neural network 1100 (e.g., a deep-learning neural network) that can be used to implement machine-learning-based image generation, feature segmentation, implicit-neural-representation generation, rendering, classification, object detection, image recognition (e.g., face recognition, object recognition, scene recognition, etc. ) , feature extraction, authentication, gaze detection, gaze prediction, and / or automation.
[0147] An input layer 1102 includes input data. Neural network 1100 includes multiple hidden layers hidden layers 1106a, 1106b, through 1106n. The hidden layers 1106a, 1106b, through hidden layer 1106n include “n” number of hidden layers, where “n” is an integer greater than or equal to one. The number of hidden layers can be made to include as many layers as needed for the given application. Neural network 1100 further includes an output layer 1104 that provides an output resulting from the processing performed by the hidden layers 1106a, 1106b, through 1106n.
[0148] Neural network 1100 may be, or may include, a multi-layer neural network of interconnected nodes. Each node can represent a piece of information. Information associated with the nodes is shared among the different layers and each layer retains information as information is processed. In some cases, neural network 1100 can include a feed-forward network, in which case there are no feedback connections where outputs of the network are fed back into itself. In some cases, neural network 1100 can include a recurrent neural network, which can have loops that allow information to be carried across nodes while reading in input.
[0149] Information can be exchanged between nodes through node-to-node interconnections between the various layers. Nodes of input layer 1102 can activate a set of nodes in the first hidden layer 1106a. For example, as shown, each of the input nodes of input layer 1102 is connected to each of the nodes of the first hidden layer 1106a. The nodes of first hidden layer 1106a can transform the information of each input node by applying activation functions to the input node information. The information derived from the transformation can then be passed to and can activate the nodes of the next hidden layer 1106b, which can perform their own designated functions. Example functions include convolutional, up-sampling, data transformation, and / or any other suitable functions. The output of the hidden layer 1106b can then activate nodes of the next hidden layer, and so on. The output of the last hidden layer 1106n can activate one or more nodes of the output layer 1104, at which an output is provided. In some cases, while nodes (e.g., node 1108) in neural network 1100 are shown as having multiple output lines, a node has a single output and all lines shown as being output from a node represent the same output value.
[0150] In some cases, each node or interconnection between nodes can have a weight that is a set of parameters derived from the training of neural network 1100. Once neural network 1100 is trained, it can be referred to as a trained neural network, which can be used to perform one or more operations. For example, an interconnection between nodes can represent a piece of information learned about the interconnected nodes. The interconnection can have a tunable numeric weight that can be tuned (e.g., based on a training dataset) , allowing neural network 1100 to be adaptive to inputs and able to learn as more and more data is processed.
[0151] Neural network 1100 may be pre-trained to process the features from the data in the input layer 1102 using the different hidden layers 1106a, 1106b, through 1106n in order to provide the output through the output layer 1104. In an example in which neural network 1100 is used to identify features in images, neural network 1100 can be trained using training data that includes both images and labels, as described above. For instance, training images can be input into the network, with each training image having a label indicating the features in the images (for the feature-segmentation machine-learning system) or a label indicating classes of an activity in each image. In one example using object classification for illustrative purposes, a training image can include an image of a number 2, in which case the label for the image can be [0 0 1 0 0 0 0 0 0 0] .
[0152] In some cases, neural network 1100 can adjust the weights of the nodes using a training process called backpropagation. As noted above, a backpropagation process can include a forward pass, a loss function, a backward pass, and a weight update. The forward pass, loss function, backward pass, and parameter update is performed for one training iteration. The process can be repeated for a certain number of iterations for each set of training images until neural network 1100 is trained well enough so that the weights of the layers are accurately tuned.
[0153] For the example of identifying objects in images, the forward pass can include passing a training image through neural network 1100. The weights are initially randomized before neural network 1100 is trained. As an illustrative example, an image can include an array of numbers representing the pixels of the image. Each number in the array can include a value from 0 to 255 describing the pixel intensity at that position in the array. In one example, the array can include a 28 x 28 x 3 array of numbers with 28 rows and 28 columns of pixels and 3 color components (such as red, green, and blue, or luma and two chroma components, or the like) .
[0154] As noted above, for a first training iteration for neural network 1100, the output will likely include values that do not give preference to any particular class due to the weights being randomly selected at initialization. For example, if the output is a vector with probabilities that the object includes different classes, the probability value for each of the different classes can be equal or at least very similar (e.g., for ten possible classes, each class can have a probability value of 0.1) . With the initial weights, neural network 1100 is unable to determine low-level features and thus cannot make an accurate determination of what the classification of the object might be. A loss function can be used to analyze error in the output. Any suitable loss function definition can be used, such as a cross-entropy loss. Another example of a loss function includes the mean squared error (MSE) , defined as The loss can be set to be equal to the value of Etotal.
[0155] The loss (or error) will be high for the first training images since the actual values will be much different than the predicted output. The goal of training is to minimize the amount of loss so that the predicted output is the same as the training label. Neural network 1100 can perform a backward pass by determining which inputs (weights) most contributed to the loss of the network and can adjust the weights so that the loss decreases and is eventually minimized. A derivative of the loss with respect to the weights (denoted as dL / dW, where W are the weights at a particular layer) can be computed to determine the weights that contributed most to the loss of the network. After the derivative is computed, a weight update can be performed by updating all the weights of the filters. For example, the weights can be updated so that they change in the opposite direction of the gradient. The weight update can be denoted as where w denotes a weight, wi denotes the initial weight, and η denotes a learning rate. The learning rate can be set to any suitable value, with a high learning rate including larger weight updates and a lower value indicating smaller weight updates.
[0156] Neural network 1100 can include any suitable deep network. One example includes a convolutional neural network (CNN) , which includes an input layer and an output layer, with multiple hidden layers between the input and out layers. The hidden layers of a CNN include a series of convolutional, nonlinear, pooling (for downsampling) , and fully connected layers. Neural network 1100 can include any other deep network other than a CNN, such as an autoencoder, a deep belief nets (DBNs) , a Recurrent Neural Networks (RNNs) , among others.
[0157] FIG. 12 is an illustrative example of a convolutional neural network (CNN) 1200. The input layer 1202 of the CNN 1200 includes data representing an image or frame. For example, the data can include an array of numbers representing the pixels of the image, with each number in the array including a value from 0 to 255 describing the pixel intensity at that position in the array. Using the previous example from above, the array can include a 28 x 28 x 3 array of numbers with 28 rows and 28 columns of pixels and 3 color components (e.g., red, green, and blue, or luma and two chroma components, or the like) . The image can be passed through a convolutional hidden layer 1204, an optional non-linear activation layer, a pooling hidden layer 1206, and fully connected layer 1208 (which fully connected layer 1208 can be hidden) to get an output at the output layer 1210. While only one of each hidden layer is shown in FIG. 12, one of ordinary skill will appreciate that multiple convolutional hidden layers, non-linear layers, pooling hidden layers, and / or fully connected layers can be included in the CNN 1200. As previously described, the output can indicate a single class of an object or can include a probability of classes that best describe the object in the image.
[0158] The first layer of the CNN 1200 can be the convolutional hidden layer 1204. The convolutional hidden layer 1204 can analyze image data of the input layer 1202. Each node of the convolutional hidden layer 1204 is connected to a region of nodes (pixels) of the input image called a receptive field. The convolutional hidden layer 1204 can be considered as one or more filters (each filter corresponding to a different activation or feature map) , with each convolutional iteration of a filter being a node or neuron of the convolutional hidden layer 1204. For example, the region of the input image that a filter covers at each convolutional iteration would be the receptive field for the filter. In one illustrative example, if the input image includes a 28×28 array, and each filter (and corresponding receptive field) is a 5×5 array, then there will be 24×24 nodes in the convolutional hidden layer 1204. Each connection between a node and a receptive field for that node learns a weight and, in some cases, an overall bias such that each node learns to analyze its particular local receptive field in the input image. Each node of the convolutional hidden layer 1204 will have the same weights and bias (called a shared weight and a shared bias) . For example, the filter has an array of weights (numbers) and the same depth as the input. A filter will have a depth of 3 for an image frame example (according to three color components of the input image) . An illustrative example size of the filter array is 5 x 5 x 3, corresponding to a size of the receptive field of a node.
[0159] The convolutional nature of the convolutional hidden layer 1204 is due to each node of the convolutional layer being applied to its corresponding receptive field. For example, a filter of the convolutional hidden layer 1204 can begin in the top-left corner of the input image array and can convolve around the input image. As noted above, each convolutional iteration of the filter can be considered a node or neuron of the convolutional hidden layer 1204. At each convolutional iteration, the values of the filter are multiplied with a corresponding number of the original pixel values of the image (e.g., the 5x5 filter array is multiplied by a 5x5 array of input pixel values at the top-left corner of the input image array) . The multiplications from each convolutional iteration can be summed together to obtain a total sum for that iteration or node. The process is next continued at a next location in the input image according to the receptive field of a next node in the convolutional hidden layer 1204. For example, a filter can be moved by a step amount (referred to as a stride) to the next receptive field. The stride can be set to 1 or any other suitable amount. For example, if the stride is set to 1, the filter will be moved to the right by 1 pixel at each convolutional iteration. Processing the filter at each unique location of the input volume produces a number representing the filter results for that location, resulting in a total sum value being determined for each node of the convolutional hidden layer 1204.
[0160] The mapping from the input layer to the convolutional hidden layer 1204 is referred to as an activation map (or feature map) . The activation map includes a value for each node representing the filter results at each location of the input volume. The activation map can include an array that includes the various total sum values resulting from each iteration of the filter on the input volume. For example, the activation map will include a 24 x 24 array if a 5 x 5 filter is applied to each pixel (astride of 1) of a 28 x 28 input image. The convolutional hidden layer 1204 can include several activation maps in order to identify multiple features in an image. The example shown in FIG. 12 includes three activation maps. Using three activation maps, the convolutional hidden layer 1204 can detect three different kinds of features, with each feature being detectable across the entire image.
[0161] In some examples, a non-linear hidden layer can be applied after the convolutional hidden layer 1204. The non-linear layer can be used to introduce non-linearity to a system that has been computing linear operations. One illustrative example of a non-linear layer is a rectified linear unit (ReLU) layer. A ReLU layer can apply the function f (x) = max (0, x) to all of the values in the input volume, which changes all the negative activations to 0. The ReLU can thus increase the non-linear properties of the CNN 1200 without affecting the receptive fields of the convolutional hidden layer 1204.
[0162] The pooling hidden layer 1206 can be applied after the convolutional hidden layer 1204 (and after the non-linear hidden layer when used) . The pooling hidden layer 1206 is used to simplify the information in the output from the convolutional hidden layer 1204. For example, the pooling hidden layer 1206 can take each activation map output from the convolutional hidden layer 1204 and generates a condensed activation map (or feature map) using a pooling function. Max-pooling is one example of a function performed by a pooling hidden layer. Other forms of pooling functions be used by the pooling hidden layer 1206, such as average pooling, L2-norm pooling, or other suitable pooling functions. A pooling function (e.g., a max-pooling filter, an L2-norm filter, or other suitable pooling filter) is applied to each activation map included in the convolutional hidden layer 1204. In the example shown in FIG. 12, three pooling filters are used for the three activation maps in the convolutional hidden layer 1204.
[0163] In some examples, max-pooling can be used by applying a max-pooling filter (e.g., having a size of 2x2) with a stride (e.g., equal to a dimension of the filter, such as a stride of 2) to an activation map output from the convolutional hidden layer 1204. The output from a max-pooling filter includes the maximum number in every sub-region that the filter convolves around. Using a 2x2 filter as an example, each unit in the pooling layer can summarize a region of 2×2 nodes in the previous layer (with each node being a value in the activation map) . For example, four values (nodes) in an activation map will be analyzed by a 2x2 max-pooling filter at each iteration of the filter, with the maximum value from the four values being output as the “max” value. If such a max-pooling filter is applied to an activation filter from the convolutional hidden layer 1204 having a dimension of 24x24 nodes, the output from the pooling hidden layer 1206 will be an array of 12x12 nodes.
[0164] In some examples, an L2-norm pooling filter could also be used. The L2-norm pooling filter includes computing the square root of the sum of the squares of the values in the 2×2 region (or other suitable region) of an activation map (instead of computing the maximum values as is done in max-pooling) and using the computed values as an output.
[0165] The pooling function (e.g., max-pooling, L2-norm pooling, or other pooling function) determines whether a given feature is found anywhere in a region of the image and discards the exact positional information. This can be done without affecting results of the feature detection because, once a feature has been found, the exact location of the feature is not as important as its approximate location relative to other features. Max-pooling (as well as other pooling methods) offer the benefit that there are many fewer pooled features, thus reducing the number of parameters needed in later layers of the CNN 1200.
[0166] The final layer of connections in the network is a fully-connected layer that connects every node from the pooling hidden layer 1206 to every one of the output nodes in the output layer 1210. Using the example above, the input layer includes 28 x 28 nodes encoding the pixel intensities of the input image, the convolutional hidden layer 1204 includes 3×24×24 hidden feature nodes based on application of a 5×5 local receptive field (for the filters) to three activation maps, and the pooling hidden layer 1206 includes a layer of 3×12×12 hidden feature nodes based on application of max-pooling filter to 2×2 regions across each of the three feature maps. Extending this example, the output layer 1210 can include ten output nodes. In such an example, every node of the 3x12x12 pooling hidden layer 1206 is connected to every node of the output layer 1210.
[0167] The fully connected layer 1208 can obtain the output of the previous pooling hidden layer 1206 (which should represent the activation maps of high-level features) and determines the features that most correlate to a particular class. For example, the fully connected layer 1208 can determine the high-level features that most strongly correlate to a particular class and can include weights (nodes) for the high-level features. A product can be computed between the weights of the fully connected layer 1208 and the pooling hidden layer 1206 to obtain probabilities for the different classes. For example, if the CNN 1200 is being used to predict that an object in an image is a person, high values will be present in the activation maps that represent high-level features of people (e.g., two legs are present, a face is present at the top of the object, two eyes are present at the top left and top right of the face, a nose is present in the middle of the face, a mouth is present at the bottom of the face, and / or other features common for a person) .
[0168] In some examples, the output from the output layer 1210 can include an M-dimensional vector (in the prior example, M=10) . M indicates the number of classes that the CNN 1200 has to choose from when classifying the object in the image. Other example outputs can also be provided. Each number in the M-dimensional vector can represent the probability the object is of a certain class. In one illustrative example, if a 10-dimensional output vector represents ten different classes of objects is [0 0 0.05 0.8 0 0.15 0 0 0 0] , the vector indicates that there is a 5%probability that the image is the third class of object (e.g., a dog) , an 80%probability that the image is the fourth class of object (e.g., a human) , and a 15%probability that the image is the sixth class of object (e.g., a kangaroo) . The probability for a class can be considered a confidence level that the object is part of that class.
[0169] FIG. 13 is a block diagram of an example transformer in accordance with some aspects of the disclosure. In a convolutional neural network (CNN) model, the number of operations required to relate signals from two arbitrary input or output positions grows in the distance between positions, which makes learning dependencies at different distant positions challenging for a CNN model. The transformer 1300 reduces the operations of learning dependencies by using an encoder 1310 and a decoder 1330 that implements an attention mechanism at different positions of a single sequence to compute a representation of that sequence. An attention function can be described as mapping a query and a set of key-value pairs to an output, where the query, keys, values, and output are all vectors. The output is computed as a weighted sum of the values, where the weight assigned to each value is computed by a compatibility function of the query with the corresponding key.
[0170] In one example of a transformer, the encoder 1310 is composed of a stack of six identical layers and each layer has two sub-layers. The first sub-layer is a multi-head self-attention engine 1312, and the second sub-layer is a fully connected feed-forward network 1314. A residual connection (not shown) connects around each of the sub-layers followed by normalization.
[0171] The decoder 1330 is also composed of a stack of six identical layers. The decoder also includes a masked multi-head self-attention engine 1332, a multi-head attention engine 1334 over the output of encoder 1310, and a fully connected feed-forward network 1326. Each layer includes a residual connection (not shown) around the layer, which is followed by layer normalization. The masked multi-head self-attention engine 1332 is masked to prevent positions from attending to subsequent positions and ensures that the predictions at position i can depend only on the known outputs at positions less than i (e.g., auto-regression) .
[0172] In the transformer 1300, the queries, keys, and values are linearly projected by a multi-head attention engine into learned linear projects, and then attention is performed in parallel on each of the learned linear projects, which are concatenated and then projected into final values.
[0173] The transformer also includes a positional encoder 1340 to encode positions because the model does not contain recurrence and convolution and relative or absolute position of the tokens is needed. For example, the positional embeddings are added to the input embeddings at the bottom layer of the encoder 1310 and the decoder 1330. The positional embeddings are summed with the embeddings because the positional embeddings and embeddings have the same dimensions. A corresponding position decoder 1350 is configured to decode the positions of the embeddings for the decoder 1330.
[0174] In some aspects, the transformer 1300 uses self-attention mechanisms to selectively weigh the importance of different parts of an input sequence during processing and allows the model to attend to different parts of the input sequence while generating the output. The input sequence is first embedded into vectors and then passed through multiple layers of self-attention and feed-forward networks. The transformer 1300 can process input sequences of variable length, making it well-suited for natural language processing tasks where input lengths can vary greatly. Additionally, the self-attention mechanism allows the transformer 1300 to capture long-range dependencies between words in the input sequence, which is difficult for RNNs and CNNs. The transformer with self-attention has achieved results in several natural language processing tasks that are beyond the capabilities of other neural networks and has become a popular choice for language and text applications. For example, the various large language models, such as a generative pretrained transformer (e.g., ChatGPT, etc. ) and other current models are types of transformer networks.
[0175] FIG. 14 illustrates an example computing device architecture 1400 of an example computing device which can implement the various techniques described herein. In some examples, the computing device can include a mobile device, a wearable device, an extended reality device (e.g., a virtual reality (VR) device, an augmented reality (AR) device, or a mixed reality (MR) device) , a personal computer, a laptop computer, a video server, a vehicle (or computing device of a vehicle) , or other device. The components of computing device architecture 1400 are shown in electrical communication with each other using connection 1405, such as a bus. The example computing device architecture 1400 includes a processing unit (CPU or processor) 1410 and computing device connection 1405 that couples various computing device components including computing device memory 1415, such as read only memory (ROM) 1420 and random access memory (RAM) 1425, to processor 1410.
[0176] Computing device architecture 1400 can include a cache of high-speed memory connected directly with, in close proximity to, or integrated as part of processor 1410. Computing device architecture 1400 can copy data from memory 1415 and / or the storage device 1430 to cache 1412 for quick access by processor 1410. In this way, the cache can provide a performance boost that avoids processor 1410 delays while waiting for data. These and other modules can control or be configured to control processor 1410 to perform various actions. Other computing device memory 1415 may be available for use as well. Memory 1415 can include multiple different types of memory with different performance characteristics. Processor 1410 can include any general purpose processor and a hardware or software service, such as service 1 1432, service 2 1434, and service 3 1436 stored in storage device 1430, configured to control processor 1410 as well as a special-purpose processor where software instructions are incorporated into the processor design. Processor 1410 may be a self-contained system, containing multiple cores or processors, a bus, memory controller, cache, etc. A multi-core processor may be symmetric or asymmetric.
[0177] To enable user interaction with the computing device architecture 1400, input device 1445 can represent any number of input mechanisms, such as a microphone for speech, a touch-sensitive screen for gesture or graphical input, keyboard, mouse, motion input, speech and so forth. Output device 1435 can also be one or more of a number of output mechanisms known to those of skill in the art, such as a display, projector, television, speaker device, etc. In some instances, multimodal computing devices can enable a user to provide multiple types of input to communicate with computing device architecture 1400. Communication interface 1440 can generally govern and manage the user input and computing device output. There is no restriction on operating on any particular hardware arrangement and therefore the basic features here may easily be substituted for improved hardware or firmware arrangements as they are developed.
[0178] Storage device 1430 is a non-volatile memory and can be a hard disk or other types of computer readable media which can store data that are accessible by a computer, such as magnetic cassettes, flash memory cards, solid state memory devices, digital versatile disks, cartridges, random access memories (RAMs) 1425, read only memory (ROM) 1420, and hybrids thereof. Storage device 1430 can include services 1432, 1434, 1436 for controlling processor 1410. Other hardware or software modules are contemplated. Storage device 1430 can be connected to the computing device connection 1405. In one aspect, a hardware module that performs a particular function can include the software component stored in a computer-readable medium in connection with the necessary hardware components, such as processor 1410, connection 1405, output device 1435, and so forth, to carry out the function.
[0179] Aspects of the present disclosure are applicable to any suitable electronic device (such as security systems, smartphones, tablets, laptop computers, vehicles, drones, or other devices) including or coupled to one or more active depth sensing systems. While described below with respect to a device having or coupled to one light projector, aspects of the present disclosure are applicable to devices having any number of light projectors, and are therefore not limited to specific devices.
[0180] The term “device” is not limited to one or a specific number of physical objects (such as one smartphone, one controller, one processing system and so on) . As used herein, a device may be any electronic device with one or more parts that may implement at least some portions of this disclosure. While the below description and examples use the term “device” to describe various aspects of this disclosure, the term “device” is not limited to a specific configuration, type, or number of objects. Additionally, the term “system” is not limited to multiple components or specific embodiments. For example, a system may be implemented on one or more printed circuit boards or other substrates, and may have movable or static components. While the below description and examples use the term “system” to describe various aspects of this disclosure, the term “system” is not limited to a specific configuration, type, or number of objects.
[0181] Specific details are provided in the description above to provide a thorough understanding of the embodiments and examples provided herein. However, it will be understood by one of ordinary skill in the art that the embodiments may be practiced without these specific details. For clarity of explanation, in some instances the present technology may be presented as including individual functional blocks including functional blocks comprising devices, device components, steps or routines in a method embodied in software, or combinations of hardware and software. Additional components may be used other than those shown in the figures and / or described herein. For example, circuits, systems, networks, processes, and other components may be shown as components in block diagram form in order not to obscure the embodiments in unnecessary detail. In other instances, well-known circuits, processes, algorithms, structures, and techniques may be shown without unnecessary detail in order to avoid obscuring the embodiments.
[0182] Individual embodiments may be described above as a process or method which is depicted as a flowchart, a flow diagram, a data flow diagram, a structure diagram, or a block diagram. Although a flowchart may describe the operations as a sequential process, many of the operations can be performed in parallel or concurrently. In addition, the order of the operations may be re-arranged. A process is terminated when its operations are completed but could have additional steps not included in a figure. A process may correspond to a method, a function, a procedure, a subroutine, a subprogram, etc. When a process corresponds to a function, its termination can correspond to a return of the function to the calling function or the main function.
[0183] Processes and methods according to the above-described examples can be implemented using computer-executable instructions that are stored or otherwise available from computer-readable media. Such instructions can include, for example, instructions and data which cause or otherwise configure a general-purpose computer, special purpose computer, or a processing device to perform a certain function or group of functions. Portions of computer resources used can be accessible over a network. The computer executable instructions may be, for example, binaries, intermediate format instructions such as assembly language, firmware, source code, etc.
[0184] The term “computer-readable medium” includes, but is not limited to, portable or non-portable storage devices, optical storage devices, and various other mediums capable of storing, containing, or carrying instruction (s) and / or data. A computer-readable medium may include a non-transitory medium in which data can be stored and that does not include carrier waves and / or transitory electronic signals propagating wirelessly or over wired connections. Examples of a non-transitory medium may include, but are not limited to, a magnetic disk or tape, optical storage media such as flash memory, memory or memory devices, magnetic or optical disks, flash memory, USB devices provided with non-volatile memory, networked storage devices, compact disk (CD) or digital versatile disk (DVD) , any suitable combination thereof, among others. A computer-readable medium may have stored thereon code and / or machine-executable instructions that may represent a procedure, a function, a subprogram, a program, a routine, a subroutine, a module, a software package, a class, or any combination of instructions, data structures, or program statements. A code segment may be coupled to another code segment or a hardware circuit by passing and / or receiving information, data, arguments, parameters, or memory contents. Information, arguments, parameters, data, etc., may be passed, forwarded, or transmitted via any suitable means including memory sharing, message passing, token passing, network transmission, or the like.
[0185] In some embodiments, the computer-readable storage devices, mediums, and memories can include a cable or wireless signal containing a bit stream and the like. However, when mentioned, non-transitory computer-readable storage media expressly exclude media such as energy, carrier signals, electromagnetic waves, and signals per se.
[0186] Devices implementing processes and methods according to these disclosures can include hardware, software, firmware, middleware, microcode, hardware description languages, or any combination thereof, and can take any of a variety of form factors. When implemented in software, firmware, middleware, or microcode, the program code or code segments to perform the necessary tasks (e.g., a computer-program product) may be stored in a computer-readable or machine-readable medium. A processor (s) may perform the necessary tasks. Typical examples of form factors include laptops, smart phones, mobile phones, tablet devices or other small form factor personal computers, personal digital assistants, rackmount devices, standalone devices, and so on. Functionality described herein also can be embodied in peripherals or add-in cards. Such functionality can also be implemented on a circuit board among different chips or different processes executing in a single device, by way of further example.
[0187] The instructions, media for conveying such instructions, computing resources for executing them, and other structures for supporting such computing resources are example means for providing the functions described in the disclosure.
[0188] In the foregoing description, aspects of the application are described with reference to specific embodiments thereof, but those skilled in the art will recognize that the application is not limited thereto. Thus, while illustrative embodiments of the application have been described in detail herein, it is to be understood that the inventive concepts may be otherwise variously embodied and employed, and that the appended claims are intended to be construed to include such variations, except as limited by the prior art. Various features and aspects of the above-described application may be used individually or jointly. Further, embodiments can be utilized in any number of environments and applications beyond those described herein without departing from the broader spirit and scope of the specification. The specification and drawings are, accordingly, to be regarded as illustrative rather than restrictive. For the purposes of illustration, methods were described in a particular order. It should be appreciated that in alternate embodiments, the methods may be performed in a different order than that described.
[0189] One of ordinary skill will appreciate that the less than ( “<” ) and greater than ( “>” ) symbols or terminology used herein can be replaced with less than or equal to ( “≤” ) and greater than or equal to ( “≥” ) symbols, respectively, without departing from the scope of this description.
[0190] Where components are described as being “configured to” perform certain operations, such configuration can be accomplished, for example, by designing electronic circuits or other hardware to perform the operation, by programming programmable electronic circuits (e.g., microprocessors or other suitable electronic circuits) to perform the operation, or any combination thereof.
[0191] The phrase “coupled to” refers to any component that is physically connected to another component either directly or indirectly and / or any component that is in communication with another component (e.g., connected to the other component over a wired or wireless connection, and / or other suitable communication interface) either directly or indirectly.
[0192] Claim language or other language reciting “at least one of” a set and / or “one or more” of a set indicates that one member of the set or multiple members of the set (in any combination) satisfy the claim. For example, claim language reciting “at least one of A and B” or “at least one of A or B” means A, B, or A and B. In another example, claim language reciting “at least one of A, B, and C” or “at least one of A, B, or C” means A, B, C, or A and B, or A and C, or B and C, or A and B and C. The language “at least one of” a set and / or “one or more” of a set does not limit the set to the items listed in the set. For example, claim language reciting “at least one of A and B” or “at least one of A or B” can mean A, B, or A and B, and can additionally include items not listed in the set of A and B.
[0193] The various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, firmware, or combinations thereof. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
[0194] The techniques described herein may also be implemented in electronic hardware, computer software, firmware, or any combination thereof. Such techniques may be implemented in any of a variety of devices such as general purposes computers, wireless communication device handsets, or integrated circuit devices having multiple uses including application in wireless communication device handsets and other devices. Any features described as modules or components may be implemented together in an integrated logic device or separately as discrete but interoperable logic devices. If implemented in software, the techniques may be realized at least in part by a computer-readable data storage medium comprising program code including instructions that, when executed, performs one or more of the methods described above. The computer-readable data storage medium may form part of a computer program product, which may include packaging materials. The computer-readable medium may comprise memory or data storage media, such as random access memory (RAM) such as synchronous dynamic random access memory (SDRAM) , read-only memory (ROM) , non-volatile random access memory (NVRAM) , electrically erasable programmable read-only memory (EEPROM) , FLASH memory, magnetic or optical data storage media, and the like. The techniques additionally, or alternatively, may be realized at least in part by a computer-readable communication medium that carries or communicates program code in the form of instructions or data structures and that can be accessed, read, and / or executed by a computer, such as propagated signals or waves.
[0195] The program code may be executed by a processor, which may include one or more processors, such as one or more digital signal processors (DSPs) , general purpose microprocessors, an application specific integrated circuits (ASICs) , field programmable logic arrays (FPGAs) , or other equivalent integrated or discrete logic circuitry. Such a processor may be configured to perform any of the techniques described in this disclosure. A general purpose processor may be a microprocessor; but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration. Accordingly, the term “processor, ” as used herein may refer to any of the foregoing structure, any combination of the foregoing structure, or any other structure or apparatus suitable for implementation of the techniques described herein.
[0196] Illustrative aspects of the disclosure include:
[0197] Aspect 1. An apparatus for training a machine learning (ML) model, comprising: at least one memory comprising instructions; and at least one processor coupled to the at least one memory and configured to: generate a first loss based on teacher features from a teacher ML model and student features from a student ML model; generate a second loss based on the student features and a label; combine the first loss and the second loss to generate a combined loss; and train the student ML model based on the combined loss.
[0198] Aspect 2. The apparatus of Aspect 1, wherein the first loss comprises a distribution loss and the second loss comprises a task loss.
[0199] Aspect 3. The apparatus of Aspect 2, wherein the distribution loss comprises a generalized Kullback-Leibler divergence (GKLD) loss, and wherein the task loss comprises a Mean Cross-Entropy (MCE) loss.
[0200] Aspect 4. The apparatus of any of Aspects 2-3, wherein the task loss comprises a smoothing Mean Cross-Entropy (MCE) loss.
[0201] Aspect 5. The apparatus of Aspect 4, wherein the at least one processor is configured to generate the smoothing MCE loss based on a one hot vector and an equal hot vector.
[0202] Aspect 6. The apparatus of any of Aspects 1-5, wherein, to train the student ML model based on the combined loss, the at least one processor is configured to train an adapter of the student ML model based on the combined loss.
[0203] Aspect 7. The apparatus of any of Aspects 1-6, wherein the teacher features include teacher logits from the teacher ML model, and wherein the student features include student logits from the student ML model.
[0204] Aspect 8. The apparatus of any of Aspects 1-7, wherein the first loss is generated based on logits obtained using on-policy sampling.
[0205] Aspect 9. The apparatus of Aspect 8, wherein the on-policy sampling generates multiple sequences based on a number of top probable sequences.
[0206] Aspect 10. The apparatus of Aspect 9, wherein the at least one processor is configured to reject a sequence, of the multiple sequences, based on a length of the sequence.
[0207] Aspect 11. A method for training a machine learning (ML) model, comprising: generating a first loss based on teacher features from a teacher ML model and student features from a student ML model; generating a second loss based on the student features and a label; combining the first loss and the second loss to generate a combined loss; and training the student ML model based on the combined loss.
[0208] Aspect 12. The method of Aspect 11, wherein the first loss comprises a distribution loss and the second loss comprises a task loss.
[0209] Aspect 13. The method of Aspect 12, wherein the distribution loss comprises a generalized Kullback-Leibler divergence (GKLD) loss, and wherein the task loss comprises a Mean Cross-Entropy (MCE) loss.
[0210] Aspect 14. The method of any of Aspects 12-13, wherein the task loss comprises a smoothing Mean Cross-Entropy (MCE) loss.
[0211] Aspect 15. The method of Aspect 14, further comprising generating the smoothing MCE loss based on a one hot vector and an equal hot vector.
[0212] Aspect 16. The method of any of Aspects 11-15, wherein training the student ML model based on the combined loss comprises training an adapter of the student ML model based on the combined loss.
[0213] Aspect 17. The method of any of Aspects 11-16, wherein the teacher features include teacher logits from the teacher ML model, and wherein the student features include student logits from the student ML model.
[0214] Aspect 18. The method of any of Aspects 11-17, wherein the first loss is generated based on logits obtained using on-policy sampling.
[0215] Aspect 19. The method of Aspect 18, wherein the on-policy sampling generates multiple sequences based on a number of top probable sequences.
[0216] Aspect 20. The method of Aspect 19, further comprising rejecting a sequence, of the multiple sequences, based on a length of the sequence.
[0217] Aspect 21. A non-transitory computer-readable medium having stored thereon instructions that, when executed by at least one processor, cause the at least one processor to perform operations according to any of Aspects 11-20
[0218] Aspect 22. An apparatus comprising one or more means for performing operations according to any one or more of Aspects 11-20.
Claims
1.An apparatus for training a machine learning (ML) model, comprising:at least one memory comprising instructions; andat least one processor coupled to the at least one memory and configured to:generate a first loss based on teacher features from a teacher ML model and student features from a student ML model;generate a second loss based on the student features and a label;combine the first loss and the second loss to generate a combined loss; andtrain the student ML model based on the combined loss.2.The apparatus of claim 1, wherein the first loss comprises a distribution loss and the second loss comprises a task loss.3.The apparatus of claim 2, wherein the distribution loss comprises a generalized Kullback-Leibler divergence (GKLD) loss, and wherein the task loss comprises a Mean Cross-Entropy (MCE) loss.4.The apparatus of claim 2, wherein the task loss comprises a smoothing Mean Cross-Entropy (MCE) loss.5.The apparatus of claim 4, wherein the at least one processor is configured to generate the smoothing MCE loss based on a one hot vector and an equal hot vector.6.The apparatus of claim 1, wherein, to train the student ML model based on the combined loss, the at least one processor is configured to train an adapter of the student ML model based on the combined loss.7.The apparatus of claim 1, wherein the teacher features include teacher logits from the teacher ML model, and wherein the student features include student logits from the student ML model.8.The apparatus of claim 1, wherein the first loss is generated based on logits obtained using on-policy sampling.9.The apparatus of claim 8, wherein the on-policy sampling generates multiple sequences based on a number of top probable sequences.10.The apparatus of claim 9, wherein the at least one processor is configured to reject a sequence, of the multiple sequences, based on a length of the sequence.11.A method for training a machine learning (ML) model, comprising:generating a first loss based on teacher features from a teacher ML model and student features from a student ML model;generating a second loss based on the student features and a label;combining the first loss and the second loss to generate a combined loss; andtraining the student ML model based on the combined loss.12.The method of claim 11, wherein the first loss comprises a distribution loss and the second loss comprises a task loss.13.The method of claim 12, wherein the distribution loss comprises a generalized Kullback-Leibler divergence (GKLD) loss, and wherein the task loss comprises a Mean Cross-Entropy (MCE) loss.14.The method of claim 12, wherein the task loss comprises a smoothing Mean Cross-Entropy (MCE) loss.15.The method of claim 14, further comprising generating the smoothing MCE loss based on a one hot vector and an equal hot vector.16.The method of claim 11, wherein training the student ML model based on the combined loss comprises training an adapter of the student ML model based on the combined loss.17.The method of claim 11, wherein the teacher features include teacher logits from the teacher ML model, and wherein the student features include student logits from the student ML model.18.The method of claim 11, wherein the first loss is generated based on logits obtained using on-policy sampling.19.The method of claim 18, wherein the on-policy sampling generates multiple sequences based on a number of top probable sequences.20.The method of claim 19, further comprising rejecting a sequence, of the multiple sequences, based on a length of the sequence.