Token cutting method and device, equipment, storage medium and program product

By using a token pruning sub-model generated through adversarial training, redundant tokens are dynamically identified based on a similarity graph. This solves the problem of low pruning accuracy in edge-cloud collaborative scenarios and achieves efficient feature compression and accurate downstream task inference.

CN122065896APending Publication Date: 2026-05-19ZHEJIANG GEELY HLDG GRP CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHEJIANG GEELY HLDG GRP CO LTD
Filing Date
2026-01-23
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

In edge-cloud collaboration scenarios, existing token clipping methods based on fixed clipping thresholds cannot be adaptively adjusted, resulting in low clipping accuracy.

Method used

A pre-defined token pruning sub-model is used to generate a dynamic pruning strategy through adversarial training. Pruning is performed based on the similarity relationship of token features before and after perturbation. A similarity graph is constructed and similar connection weights are calculated to dynamically identify redundant tokens.

Benefits of technology

It achieves adaptive pruning for different input content, improves pruning accuracy, reduces communication overhead and latency, and ensures high-precision inference for downstream tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122065896A_ABST
    Figure CN122065896A_ABST
Patent Text Reader

Abstract

The invention discloses a Token clipping method and device, equipment, a storage medium and a program product, and relates to the technical field of data processing, Token clipping is not carried out according to a fixed static threshold value, a corresponding Token clipping strategy is output through a preset Token clipping sub-model for a first Token feature sequence dynamically output by a model, and input adaptability is achieved; since the preset Token clipping sub-model is obtained by performing adversarial training on the preset to-be-trained model containing the Token clipping sub-model according to the similarity relationship between the Token features before and after disturbance, the clipping strategy can be adaptively adjusted for different input contents; cutting the first Token feature sequence according to a Token cutting strategy to obtain a high-precision cut target sequence; therefore, the cutting precision can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to token trimming methods, apparatus, devices, storage media, and program products. Background Technology

[0002] In edge-cloud collaboration scenarios, token pruning is often used to reduce the number of feature dimensions that need to be uploaded to the cloud in order to solve bandwidth pressure and latency issues. For example, a fixed pruning threshold can be set in advance, and tokens below the pruning threshold can be pruned during model inference based on their importance scores.

[0003] However, edge-cloud collaboration scenarios have high requirements for data cropping accuracy. The above-mentioned token cropping method based on a fixed cropping threshold cannot adaptively adjust to different input content, resulting in low cropping accuracy. Summary of the Invention

[0004] The main purpose of this application is to provide a token trimming method, apparatus, device, storage medium, and program product, which aims to solve the technical problem of low token trimming accuracy.

[0005] To achieve the above objectives, this application proposes a token pruning method applied to edge devices, the method comprising: Obtain the first token feature sequence of the model's current output; Based on the first token feature sequence, a token pruning strategy is output through a preset token pruning sub-model. The preset token pruning sub-model is obtained by adversarial training of a preset training model containing the token pruning sub-model based on the similarity relationship between the token features before and after perturbation. The first token feature sequence is pruned according to the token pruning strategy to obtain the pruned target sequence.

[0006] In one embodiment, the step of outputting a token pruning strategy based on the first token feature sequence using a preset token pruning sub-model includes: The similarity between every two token features in the first token feature sequence is calculated using a preset token clipping sub-model. Each token feature is used as a graph node, and the similarity is used as an edge to construct a target similarity graph; Based on the target similarity graph, the sum of similarity connection weights for each token feature is calculated, and the sum of similarity connection weights is used as the first importance of the token feature. Based on the first importance and the preset pruning rate, output the token pruning strategy.

[0007] In one embodiment, before the step of obtaining the first token feature sequence currently output by the model, the method further includes: Obtain the second token feature sequence from the model's historical output; Construct an original similarity graph between every two token features in the second token feature sequence, wherein the original similarity graph is used to characterize the similarity relationship between every two token features in the second token feature sequence; Perturbation noise is applied to the original similarity graph to generate a perturbed similarity graph; Based on the original similarity graph, the perturbed similarity graph, and the target task loss function, the preset training model containing the Token pruning sub-model is subjected to adversarial training to obtain the preset Token pruning sub-model.

[0008] In one embodiment, the step of performing adversarial training on a preset training model containing a token pruning sub-model based on the original similarity graph, the perturbed similarity graph, and the target task loss function to obtain the preset token pruning model includes: The second importance of the token feature is obtained by calculating the sum of the similarity connection weights between each token feature and other features in the original similarity graph. Sort the items according to the second importance to obtain an importance list; Based on the preset clipping rate, the redundant tokens and tokens to be retained in the importance list are determined by a differentiable sampling strategy algorithm. Based on the redundant tokens and the tokens to be retained, the target task loss is calculated using the target task loss function. Based on the perturbation-induced relationship graph and the target task loss, adversarial training is performed on the preset training model containing the Token pruning sub-model to obtain the preset Token pruning model.

[0009] In one embodiment, the step of performing adversarial training on a preset training model containing a token pruning sub-model based on the perturbated relationship graph and the target task loss to obtain the preset token pruning model includes: The gradients of the target task loss with respect to the original similarity graph and the perturbated similarity graph are calculated, respectively, to obtain the original gradient matrix and the perturbated gradient matrix. The gradient matrix is ​​used to reflect the sensitivity of the model to the similarity relationship between tokens. Based on the original gradient matrix and the perturbed gradient matrix, a consistency constraint loss is constructed, wherein the preset consistency constraint loss is used to maintain the consistency of the model's judgment on the importance of the token under the similarity graph and the perturbed graph; Based on the target task loss and consistency constraint loss, the model parameters of the preset training model are iteratively optimized using gradient descent until a preset lightweight neural network model containing the preset token pruning sub-model is obtained that meets the preset accuracy condition.

[0010] In one embodiment, before the step of obtaining the first token feature sequence currently output by the model, the method further includes: The input data is processed by the target layer Transformer in the preset lightweight neural network model to obtain the first token feature sequence. The preset lightweight neural network model includes a preset Transformer sub-model, which is a multi-layer structure. Each layer Transformer has a token pruning sub-model integrated at its output. The target layer Transformer is any layer in the multi-layer structure. The input data is the original data or the token features output by the previous layer Transformer corresponding to the target layer.

[0011] In one embodiment, after the step of pruning the first token feature sequence according to the token pruning strategy to obtain the pruned target sequence, the method further includes: When the target layer Transformer is not the last layer of the preset Transformer sub-model, the target sequence is passed to the next layer Transformer corresponding to the target layer, so that the next layer Transformer can continue to process the target sequence and update the first Token feature sequence. When the target Transformer is the last layer of the preset Transformer sub-model, the target sequence is sent to the cloud so that the cloud can perform inference on the corresponding task of the current input data based on the pruned target sequence.

[0012] Furthermore, to achieve the above objectives, this application also proposes a token trimming device, which includes: The first acquisition module is used to acquire the first token feature sequence currently output by the model; The model processing module is used to output a token pruning strategy based on the first token feature sequence through a preset token pruning sub-model. The preset token pruning sub-model is obtained by adversarial training of a preset training model containing the token pruning sub-model based on the similarity relationship between the token features before and after perturbation. The pruning module is used to prune the first token feature sequence according to the token pruning strategy to obtain the pruned target sequence.

[0013] In addition, to achieve the above objectives, this application also proposes a token trimming device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the token trimming method as described above.

[0014] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and which, when executed by a processor, implements the steps of the Token pruning method described above.

[0015] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the Token trimming method described above.

[0016] One or more technical solutions proposed in this application have at least the following technical effects: This application obtains the first token feature sequence currently output by the model; based on the first token feature sequence, it outputs a token pruning strategy through a preset token pruning sub-model; it can be understood that this application does not perform token pruning based on a fixed static threshold, but rather outputs a corresponding token pruning strategy for the first token feature sequence dynamically output by the model through a preset token pruning sub-model, which has input adaptability; since the preset token pruning sub-model is obtained by adversarial training on a preset training model containing the token pruning sub-model based on the similarity relationship between token features before and after perturbation, the token pruning sub-model can generate accurate token pruning strategies through similarity perturbation and adversarial training, realizing adaptive adjustment of the pruning strategy for different input content; by pruning the first token feature sequence according to the token pruning strategy, a high-precision pruned target sequence can be obtained; therefore, this application can improve pruning accuracy. Attached Figure Description

[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a flowchart illustrating the first embodiment of the token trimming method in this application. Figure 2 This is a schematic diagram of the logical architecture provided for Embodiment 1 of the Token trimming method in this application; Figure 3 This is a schematic diagram of the module structure of the token trimming device in an embodiment of this application; Figure 4 This is a schematic diagram of the device structure of the hardware operating environment involved in the Token trimming method in this application embodiment.

[0020] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0021] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0022] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0023] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or token trimming device capable of performing the above functions. The following description uses a token trimming device as an example to illustrate this embodiment and the subsequent embodiments.

[0024] Based on this, this application provides a token pruning method, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the token trimming method in this application.

[0025] In this embodiment, the token trimming method includes steps S10 to S30: Step S10: Obtain the first token feature sequence currently output by the model; Step S20: Based on the first Token feature sequence, output a Token pruning strategy through a preset Token pruning sub-model. The preset Token pruning sub-model is obtained by adversarial training of a preset training model containing the Token pruning sub-model based on the similarity relationship between the Token features before and after perturbation. Step S30: Prune the first Token feature sequence according to the Token pruning strategy to obtain the pruned target sequence.

[0026] It's important to note that in edge-cloud collaboration scenarios, token pruning is typically used to reduce the number of feature dimensions that need to be uploaded to the cloud, addressing bandwidth constraints and latency issues. For example, a fixed pruning threshold is pre-set, and tokens below this threshold are pruned during model inference based on their importance scores. However, edge-cloud collaboration scenarios demand high precision in data pruning. The aforementioned token pruning method based on a fixed threshold cannot adaptively adjust to different input content, resulting in low pruning accuracy.

[0027] This embodiment aims to adaptively adjust the clipping strategy to different input content, thereby improving the accuracy of token clipping.

[0028] It should be noted that the token pruning device belongs to the edge device, the edge device belongs to the end-to-cloud collaborative system, and the end-to-cloud collaborative system also includes a cloud server; the edge device is equipped with a preset lightweight neural network model, such as the Vision Transformer encoder or a lightweight BERT variant.

[0029] In actual operation, the edge device first uses its locally deployed, pre-defined lightweight neural network model to perform preliminary feature extraction on the original input data, generating the first token feature sequence, such as... Figure 2 The edge feature extraction is shown. Due to the high dimensionality and large data volume of this sequence, directly uploading it to a cloud server would result in significant communication overhead and latency, especially in bandwidth-constrained or high-concurrency scenarios.

[0030] The original input data can be at least one of image data, voice data, text data, or IoT sensor data.

[0031] Specifically, the first token feature sequence can be the original token embedding vector sequence output by a pre-defined lightweight neural network model (e.g., Vision Transformer, BERT, or a lightweight variant thereof) deployed locally at the edge, after performing forward inference on the current input data (e.g., image patches, text fragments, or sensor time-series signals). This original token embedding vector sequence typically contains multiple tokens, each token corresponding to a semantic unit of the input data (e.g., an image patch in an image, a word or sub-word unit in text), and represents its semantic and contextual information in the form of a high-dimensional vector.

[0032] Before the step of obtaining the first token feature sequence of the current output of the model, the method further includes: The input data is processed by the target layer Transformer in the preset lightweight neural network model to obtain the first token feature sequence.

[0033] Specifically, when the preset lightweight neural network model is Vision Transformer, the specific implementation method for processing the input data using the preset lightweight neural network model is as follows: Vision Transformer is used to extract features from the original image data, divide it into several image patches, and generate a visual feature set representing the semantic information of each image patch through a self-attention mechanism. ; in, This is the token feature sequence for the current batch. For the first The feature vector of each token =1,2,3, N, This represents the total length of the token sequence.

[0034] When the preset lightweight neural network model is a lightweight BERT variant, the specific implementation method for processing the input data through the preset lightweight neural network model is as follows: the lightweight BERT variant is used to perform word segmentation and context encoding on the original text data, and output the context-aware feature sequence of the corresponding token.

[0035] This embodiment uses the Vision Transformer as the preset lightweight neural network model and the original image data as the original input data for specific illustration.

[0036] It should be noted that the preset lightweight neural network model includes a preset Transformer sub-model, which is a multi-layer structure. Each Transformer layer has a Token pruning sub-model integrated at its output. The target Transformer layer can be any layer in the multi-layer structure. The input data is either the original data or the Token features output by the previous Transformer layer corresponding to the target layer.

[0037] It can be understood that when the target layer Transformer is the first layer in a multi-layer structure, the input data is the original data; when the target layer Transformer is another layer in a multi-layer structure besides the first layer, the input data is the token feature output by the previous layer Transformer corresponding to the target layer.

[0038] Therefore, the step of processing the input data through the target layer Transformer in the preset lightweight neural network model to obtain the first token feature sequence can be: processing the original input data through the first layer in the preset lightweight neural network model to obtain the first token feature sequence, or processing the input data through other layers in the preset lightweight neural network model other than the first layer to obtain the first token feature sequence.

[0039] By integrating a Token pruning sub-model at the output of each Transformer layer, edge devices can prune the Token feature sequence through multiple Token pruning sub-models, thereby achieving maximum feature compression and providing high-precision, low-overhead feature transmission; or, based on task requirements and resource constraints, the pruning timing can be dynamically selected at any network depth to achieve multi-level, progressive feature compression and transmission optimization.

[0040] After the input data is processed by the target layer Transformer in the preset lightweight neural network model to obtain the first token feature sequence, the token pruning device in the edge device can actively trigger the acquisition of the first token feature sequence of the current output of the model according to task requirements and resource constraints. Alternatively, after the preset lightweight neural network model completes each forward calculation of the target layer, the token pruning device can acquire the output cache of the target layer and use it as the first token feature sequence.

[0041] It is understandable that after the token trimming device obtains the first token feature sequence currently output by the model, it inputs it into the preset token trimming sub-model. Based on the first token feature sequence, the preset token trimming sub-model can output an adaptive token trimming strategy.

[0042] Since the preset token pruning sub-model is obtained by adversarially training a preset training model containing the token pruning sub-model based on the similarity relationship between token features before and after perturbation, the token pruning strategy of the preset token pruning sub-model remains stable when faced with small perturbations in the input features, and the pruned features can still maintain a high degree of similarity with the original features in the semantic space. Therefore, the sub-model can accurately identify the tokens that are truly critical to downstream tasks (such as classification tasks, detection tasks, or generation tasks), avoiding the loss of semantic information due to blind pruning.

[0043] The preset token pruning sub-model can be a lightweight neural network module (e.g., an MLP consisting of 1 to 2 fully connected layers, or an attention scorer with gating mechanism); the preset training model can be a visual encoder to be trained or a multimodal encoder to be trained, wherein the preset training model integrates the preset token pruning sub-module; during the training process, a visual encoder containing the preset token pruning sub-module is obtained by training the visual encoder to be trained that integrates the preset token pruning sub-module.

[0044] Specifically, the token pruning strategy output by the pre-defined token pruning sub-model may include at least one of the following: token importance score, binary / sparse pruning mask, and token index set to be retained. That is, the token pruning strategy is used to guide the subsequent selective retention of the first token feature sequence.

[0045] In one feasible implementation, the method of outputting a token pruning strategy based on the first token feature sequence through a preset token pruning sub-model can be as follows: by using a lightweight self-attention module of the preset token pruning sub-model to output the relative importance of each token in the global context, pooling or projecting the attention output to generate a scalar importance score for each token, and outputting a token pruning strategy based on the scalar importance score. This method can capture the semantic dependencies between tokens and avoid isolated evaluation.

[0046] In another feasible implementation, the method of outputting a token pruning strategy based on the first token feature sequence through a preset token pruning sub-model can be: The similarity between every two token features in the first token feature sequence is calculated using a preset token pruning sub-model; each token feature is treated as a graph node, and the similarity is treated as an edge to construct a target similarity graph; based on the target similarity graph, the sum of similarity connection weights of each token feature is calculated, and the sum of similarity connection weights is used as the first importance of the token feature; based on the first importance and a preset pruning rate, a token pruning strategy is output.

[0047] Specifically, the preset Token pruning sub-model calculates the cosine similarity or normalized dot product between every two tokens in any first token feature sequence, and uses this as the similarity between every two tokens; each token feature is treated as a graph node. Using the similarity as edges, an undirected weighted graph is constructed, resulting in a target similarity graph, such as... Figure 2 The token similarity relationship model is shown.

[0048] This target similarity graph characterizes the semantic association strength between tokens. Highly similar tokens (e.g., repetitive texture regions in an image, synonyms in text) will form strong connections in the graph. Therefore, based on the target similarity graph, the sum of similarity connection weights for each token feature is calculated. : ; in, Let the weights be the weights from the j-th token feature to the i-th token feature. The sum of all weights associated with the i-th Token feature.

[0049] Since a smaller sum of connection weights between a token feature and other token features indicates lower similarity between that token feature and other token features in the current input, it may contain unique and irreplaceable information and should be retained, i.e., it is more important; conversely, a larger sum of connection weights between a token feature and other token features indicates higher similarity between that token feature and other token features in the current input, it may contain unimportant redundant content such as repetition, background, or common patterns, i.e., it is less important. Figure 2 The token importance assessment is shown.

[0050] Therefore, the sum of the similar connection weights can be used as the first importance of the token feature; based on the first importance and a preset pruning rate, a token pruning strategy is output, such as... Figure 2 The adaptive pruning decision is shown.

[0051] Specifically, the token features can be sorted from highest to lowest importance, and the token pruning strategy for the rN tokens before pruning can be obtained according to the preset pruning rate r.

[0052] It is understood that this embodiment employs a dynamic redundancy identification mechanism for adaptive token pruning. Unlike traditional methods that simply rely on attention weights or preset fixed thresholds for pruning, this embodiment is based on global similarity, comprehensively capturing the correlation and information overlap between tokens, thereby accurately identifying redundant tokens carrying duplicate or non-critical information. This mechanism can dynamically adjust the redundancy judgment criteria according to the input content, effectively overcoming the shortcomings of static rules in comprehensively and accurately identifying redundancy in complex or diverse input scenarios, and significantly improving the accuracy and task adaptability of pruning.

[0053] Step S30: Prune the first Token feature sequence according to the Token pruning strategy to obtain the pruned target sequence.

[0054] Specifically, if the output token pruning strategy uses a binary mask, the first token feature sequence can be pruned according to the token pruning strategy to obtain the pruned target sequence by retaining only the token features corresponding to the mask value of 1.

[0055] If an importance score vector is used, a retention ratio can be set to achieve approximate pruning, so as to balance end-to-end training optimization and inference efficiency.

[0056] Further, after the step of pruning the first token feature sequence according to the token pruning strategy to obtain the pruned target sequence, the method further includes: When the target layer Transformer is not the last layer of the preset Transformer sub-model, the target sequence is passed to the next layer Transformer corresponding to the target layer, so that the next layer Transformer can continue to process the target sequence and update the first Token feature sequence; when the target layer Transformer is the last layer of the preset Transformer sub-model, the target sequence is sent to the cloud, so that the cloud can perform inference on the corresponding task of the current input data based on the pruned target sequence.

[0057] It is understood that when the target layer Transformer is not the last layer of the preset Transformer sub-model, the pruned target sequence is used as input and passed to the next layer Transformer corresponding to the target layer. This allows the next layer Transformer to continue feature extraction and context modeling based on the simplified token set, and updates the output of the next layer with a new token feature sequence for possible subsequent pruning or processing. This process eliminates redundant information in advance and reduces the computational load of subsequent layers.

[0058] When the target Transformer layer is the last layer of a preset Transformer sub-model, the inference process at the edge is terminated, and the cropped target sequence is uploaded to the cloud server via the network. The cloud server then uses this concise yet semantically complete feature sequence to perform high-precision inference on downstream tasks (such as image classification, object detection, text understanding, or question answering) corresponding to the current input data. This ensures that the finally uploaded features retain task discriminativeness while being compressed to the maximum extent. By flexibly configuring the target layer position, a dynamic balance can be achieved between computational overhead, communication costs, and task accuracy, fully adapting to the edge-cloud collaboration needs under different edge device capabilities and network environments. Figure 2 The token trimming and transmission are shown.

[0059] Specifically, the edge device can further quantize, entropy encode, or compress the token features in the target sequence through post-processing, and then upload the processed and retained token sequence to the cloud server to achieve lightweight transmission.

[0060] It should be noted that large-scale multimodal models (such as multimodal large language models, vision-language joint models, etc.) can be deployed on cloud servers. After receiving the target sequence uploaded by the edge device, the cloud server uses the target sequence as part of the input context and combines it with other modal information (such as text prompts, historical dialogues, or auxiliary metadata) to complete high-precision inference for complex downstream tasks.

[0061] Since the edge has eliminated a large number of redundant features through an adaptive token pruning mechanism, the amount of data uploaded to the cloud has been significantly reduced, effectively alleviating bandwidth pressure and transmission latency. At the same time, the retained tokens can still fully support the accurate reconstruction and understanding of key semantics by large-scale multimodal models, thereby achieving synergistic optimization between communication efficiency, edge resource consumption and cloud inference performance.

[0062] When the cloud server receives the target sequence or the processed retained token sequence uploaded by the edge device, it can decode and restore the target sequence, or perform inverse quantization or decompression operations accordingly to reconstruct an approximate floating-point feature representation. Since the token retained by the edge device fully covers the key semantic content in the input data, even if the length of the first token feature sequence is greatly reduced, the decoded features can still maintain a semantic structure and task discrimination ability that are highly consistent with the original complete features.

[0063] The cloud server directly inputs the reconstructed features into the multimodal large model deployed in the cloud, without requiring any modification to the model structure, input interface, or training weights. The multimodal large model in the cloud treats the simplified features as standard input and performs subsequent cross-modal fusion, context modeling, and task inference normally, ultimately outputting high-precision results (such as object detection boxes and categories, image-text question-answering answers, scene description text, etc.). The inference accuracy in the cloud is almost unaffected, achieving a synergistic optimization effect of low transmission cost and high task performance.

[0064] Compared to traditional token pruning methods that use fixed thresholds or statically learned thresholds, this embodiment can dynamically generate pruning strategies for different input data, achieving fine-grained, content-aware feature selection. This effectively avoids the loss of key information caused by one-size-fits-all pruning and significantly reduces unnecessary feature transmission. Furthermore, this embodiment directly embeds the adaptive pruning mechanism into a lightweight neural network model. The entire pruning process can be completed in a single forward inference at the edge, without additional communication overhead, feedback loops, or online fine-tuning. Its simple structure and convenient deployment make it particularly suitable for edge devices with limited computing resources, storage, and bandwidth.

[0065] Furthermore, this embodiment optimizes the pruning sub-model through an adversarial training mechanism based on the similarity relationship of token features before and after perturbation. This enables the sub-model to accurately identify key tokens even at high pruning rates, maximizing the removal of redundant features. In other words, by integrating dynamic redundancy identification, graph structure similarity modeling, and adversarial training, this embodiment can intelligently identify and remove redundant information, significantly reducing the amount of data transmitted from the edge to the cloud while effectively maintaining high inference accuracy for downstream tasks.

[0066] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description and will not be repeated hereafter. Based on this, before the step of obtaining the first Token feature sequence currently output by the model, the following implementation method is also included: Obtain the second token feature sequence from the model's historical output; construct an original similarity graph between every two token features in the second token feature sequence, wherein the original similarity graph is used to characterize the similarity relationship between every two token features in the second token feature sequence; apply perturbation noise to the original similarity graph to generate a perturbation graph; perform adversarial training on a preset training model containing a token pruning sub-model based on the original similarity graph, the perturbation graph, and the target task loss function to obtain the preset token pruning sub-model.

[0067] Specifically, the second token feature sequence can be an intermediate output sampled from the historical inference process of a lightweight neural network model deployed locally on an edge device during the model training phase.

[0068] It should be noted that the similarity relationship can be cosine similarity, distance metric, or clustering result, etc. The specific implementation of constructing the original similarity relationship graph between every two token features in the second token feature sequence can be: by calculating the similarity between any two tokens in the second token feature sequence, the original similarity relationship graph is constructed based on the similarity relationship.

[0069] The similarity graph can be a similarity matrix or an undirected weighted graph, etc.

[0070] Furthermore, in order to further mine important tokens and ensure the robustness of pruning decisions, controllable perturbation noise can be applied to the original similarity graph to generate a perturbed graph, thereby simulating feature fluctuations caused by input changes, sensor noise, or quantization errors in real-world scenarios; for example, adding Gaussian noise to the similarity matrix, randomly zeroing some edges, or introducing small perturbations to the original token features before reconstructing the graph.

[0071] Specifically, it can be directed to the similarity matrix. Add random perturbation noise of a certain magnitude. (e.g., Gaussian noise with zero mean), to obtain the perturbed relation matrix. This perturbation is designed to challenge the model's pruning decisions, requiring the model to identify the truly critical connections.

[0072] During adversarial training, the similarity relationships between token features in the original similarity graph and the perturbed graph are input into a preset training model containing a token pruning sub-model. The corresponding pruning strategy is output, and the pruned features are obtained. The pruned features are input into the downstream task head to obtain the prediction result. Based on the target task loss function, the loss between the prediction result and the true label is calculated. Based on the loss result, adversarial training is performed on the preset training model containing the token pruning sub-model to obtain the preset token pruning sub-model.

[0073] The target task loss can be classification cross-entropy, detection regression loss, etc., to ensure that the pruned features can still support high-precision inference.

[0074] Specifically, the specific implementation of performing adversarial training on the preset training model containing the Token pruning sub-model based on the original similarity graph, the perturbed similarity graph, and the target task loss function to obtain the preset Token pruning model can also be as follows: The second importance of each token feature is obtained by summing the similarity connection weights between each token feature and other features in the original similarity graph. The second importance is then sorted to obtain an importance list. Based on a preset pruning rate, redundant tokens and tokens to be retained in the importance list are determined using a differentiable sampling strategy algorithm. The target task loss is calculated based on the redundant tokens and tokens to be retained using the target task loss function. Adversarial training is then performed on a preset training model containing the token pruning sub-model based on the perturbated graph and the target task loss to obtain the preset token pruning sub-model.

[0075] The second importance of each token feature is calculated by summing the similarity connection weights between each token feature and other features in the original similarity graph. The sum of these weights reflects the semantic redundancy of the token within the overall feature set: a larger value indicates greater similarity to more tokens, suggesting more likely redundant information; a smaller value indicates a greater likelihood of carrying unique semantics. All tokens are sorted by their second importance scores from smallest to largest, generating a list of token importance. Tokens ranked higher in this list are considered more unique and should be retained.

[0076] Based on a preset pruning rate *r*, a differentiable sampling strategy algorithm is used to select tokens to be retained and redundant tokens from the importance list. This outputs an approximately binary, differentiable pruning mask, enabling the model to optimize the token pruning strategy during training through gradient backpropagation. Based on this differentiable pruning mask, each token feature in the original similarity graph is weighted and pruned to obtain simplified features. These simplified features are then input into a downstream task head (such as a classifier, detector, or multimodal decoder) to calculate the target task loss. This process is repeated to obtain the token pruning mask, simplified features, and target task loss under the perturbation path. Based on the task loss corresponding to the original features and the task loss corresponding to the perturbation features, adversarial training is performed on the preset training model containing the token pruning sub-model to obtain the preset token pruning sub-model.

[0077] The differentiable sampling strategy algorithm can be Gumbel-Softmax Top-K, SparseMAP, or continuous relaxation sorting, etc. For each token, based on its importance score, the retention probability is sampled from it using the differentiable sampling strategy algorithm, thus simulating a softened version of the real binary pruning decision. During the training phase, the process of selecting redundant tokens and tokens to be retained from the importance list according to a preset pruning rate is simulated using the differentiable sampling strategy, allowing gradient backpropagation to optimize the token pruning strategy.

[0078] This embodiment utilizes similarity graphs before and after perturbation to drive importance assessment, achieving semantically aware redundancy recognition. Differentiable sampling supports gradient backpropagation, allowing the pruning strategy to be supervised by the target task, and the model can adaptively adjust the preset pruning rate based on the characteristics of the input data. When the input data contains a large amount of redundant information, the preset pruning rate can be relatively large, meaning more tokens will be pruned; while when processing complex data with less redundancy, the preset pruning rate will be smaller, preserving as much information as possible. Since the entire pruning process is end-to-end differentiable, the pruning rate decision is directly supervised by the target task loss and can be optimized through gradient backpropagation. Therefore, the pruning behavior of each layer is tightly coupled with the overall task performance, forming an adaptive compression strategy that prunes as needed and adapts to different layers.

[0079] Specifically, the step of performing adversarial training on a preset training model containing a token pruning sub-model based on the perturbated relationship graph and the target task loss to obtain the preset token pruning model can also be: The gradients of the target task loss with respect to the original similarity graph and the perturbed graph are calculated, resulting in the original gradient matrix and the perturbed gradient matrix, respectively. The gradient matrix reflects the model's sensitivity to the similarity relationships between tokens. Based on the original gradient matrix and the perturbed gradient matrix, a consistency constraint loss is constructed, which maintains the consistency of the model's judgment on the importance of tokens under the similarity graph and the perturbed graph. Based on the target task loss and the consistency constraint loss, the model parameters of the preset training model are iteratively optimized using gradient descent until a preset lightweight neural network model containing the preset token pruning sub-model that meets the preset accuracy condition is obtained.

[0080] The gradients of the target task loss with respect to the original similarity graph and the perturbed similarity graph can be calculated by automatic differentiation or explicit differentiation, respectively, to obtain the original gradient matrix and the perturbed gradient matrix. The gradient matrix reflects the sensitivity of the model to changes in the similarity relationship between tokens under the current parameters. This sensitivity can indirectly reveal which semantic associations between token features are more important for task discriminability.

[0081] The gradient matrix can be expressed as: ; in, The perturbation relation matrix is... For parameters gradient operator, For parameters The likelihood estimate.

[0082] Based on the original gradient matrix and the perturbed gradient matrix, a consistency constraint loss is constructed. This pre-defined consistency constraint loss is used to maintain the model's consistent judgment of token importance under both the similarity graph and the perturbed graph. By minimizing the consistency constraint loss, the model is forced to focus on key token connections that still significantly affect the task loss even with added noise perturbations, helping to more accurately identify information crucial to the task. Specifically, the consistency constraint loss can be a gradient direction alignment loss or a gradient magnitude difference penalty.

[0083] The consistency constraint loss can be expressed as: ; Where G is the gradient matrix, This is a similarity matrix. For parameters gradient operator, For parameters The likelihood estimate.

[0084] Furthermore, the target task loss and consistency constraint loss are weighted and fused together to form the overall training objective: ; in, For the total loss function, The target task loss function, Let λ be the consistency constraint loss function, and λ be a hyperparameter.

[0085] Based on the overall training objective (i.e., the target task loss and the consistency constraint loss), the model parameters (including the backbone network and the token pruning sub-model) of the preset training model are iteratively optimized using the gradient descent method until a preset lightweight neural network model containing the preset token pruning sub-model is obtained that meets the preset accuracy condition.

[0086] The preset accuracy conditions include at least one of the following: validation set task performance convergence, pruning rate meeting the standard, or loss below a threshold.

[0087] In this embodiment, a multi-objective joint optimization strategy is employed during the training phase. Standard task losses (e.g., classification cross-entropy, detection regression loss, or multimodal question-answering loss) are weighted and fused with consistency constraint losses to jointly guide the parameter updates of the entire lightweight neural network model, including the backbone Transformer module and a learnable Token pruning decision sub-module. The standard task loss ensures that the pruned features still support high-precision downstream task inference, while the consistency constraint loss, through an adversarial training mechanism, guarantees the robustness of the pruning strategy to input perturbations. By minimizing this joint loss end-to-end, the model gradually learns to adaptively balance compression ratio and task accuracy: boldly pruning on highly redundant samples and cautiously retaining information-dense regions. After training, the resulting Token pruning sub-model can achieve efficient and accurate feature compression during the inference phase without cloud feedback or modification of the backbone structure.

[0088] Furthermore, based on the similarity relationship between the token features before and after the perturbation, the model is trained adversarially, which enables the model to stably identify and retain tokens that truly contribute to the task even when faced with input noise, quantization errors, or distribution shifts. This effectively avoids the accidental deletion of key information and significantly improves the robustness, generalization, and interpretability of pruning decisions.

[0089] Therefore, this embodiment utilizes task-driven joint training and gradient-aware adversarial optimization (such as...) Figure 2 The adversarial perturbation and gradient optimization shown demonstrate efficient, intelligent, and adaptive token pruning for edge-cloud collaborative scenarios.

[0090] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the token trimming method of this application. Any simple transformations based on this technical concept are within the protection scope of this application.

[0091] This application also provides a token trimming device, please refer to... Figure 3 The token trimming device includes: The first acquisition module 10 is used to acquire the first token feature sequence currently output by the model; The model processing module 20 is used to output a token pruning strategy based on the first token feature sequence through a preset token pruning sub-model. The preset token pruning sub-model is obtained by adversarial training of a preset training model containing the token pruning sub-model based on the similarity relationship between the token features before and after perturbation. The trimming module 30 is used to trim the first token feature sequence according to the token trimming strategy to obtain the trimmed target sequence.

[0092] In one embodiment, the trimming module 30 includes: The first calculation submodule is used to calculate the similarity between every two token features in the first token feature sequence through a preset token pruning sub-model. A submodule is constructed to use each token feature as a graph node and the similarity as an edge to construct a target similarity graph. The second calculation submodule is used to calculate the sum of similarity connection weights for each Token feature based on the target similarity relationship graph, and to use the sum of similarity connection weights as the first importance of the Token feature; The output submodule is used to output a token clipping strategy based on the first importance and the preset clipping rate.

[0093] In one embodiment, before the step of obtaining the first token feature sequence currently output by the model, the token trimming device further includes: The second acquisition module is used to acquire the second token feature sequence of the model's historical output; A construction module is used to construct an original similarity graph between every two token features in the second token feature sequence, wherein the original similarity graph is used to characterize the similarity relationship between every two token features in the second token feature sequence; The generation module is used to apply perturbation noise to the original similarity graph to generate a perturbed similarity graph; The training module is used to perform adversarial training on a preset training model containing a token pruning sub-model based on the original similarity graph, the perturbed similarity graph, and the target task loss function, so as to obtain the preset token pruning sub-model.

[0094] In one embodiment, the training module includes: The third calculation submodule is used to calculate the sum of similarity connection weights between each Token feature and other features in the original similarity graph, and to obtain the second importance of the Token feature; The sorting submodule is used to sort the second importance to obtain an importance list; The determination submodule is used to determine the redundant tokens and tokens to be retained in the importance list based on a preset clipping rate and a differentiable sampling strategy algorithm. The fourth calculation submodule is used to calculate the target task loss based on the redundant token and the token to be retained using the target task loss function. The training submodule is used to perform adversarial training on a preset training model containing a token pruning submodel based on the perturbation relationship graph and the target task loss, so as to obtain the preset token pruning submodel.

[0095] In one embodiment, the training submodule includes: The computing unit is used to calculate the gradient of the target task loss with respect to the original similarity graph and the perturbed similarity graph, respectively, to obtain the original gradient matrix and the perturbed gradient matrix. The gradient matrix is ​​used to reflect the sensitivity of the model to the similarity relationship between tokens. The construction unit is used to construct a consistency constraint loss based on the original gradient matrix and the perturbed gradient matrix, wherein the preset consistency constraint loss is used to maintain the consistency of the model's judgment on the importance of the token under the similarity graph and the perturbed graph. The training unit is used to iteratively optimize the model parameters of the preset model to be trained using gradient descent based on the target task loss and consistency constraint loss, until a preset lightweight neural network model containing the preset token pruning sub-model is obtained that meets the preset accuracy condition.

[0096] In one embodiment, before the step of obtaining the first token feature sequence currently output by the model, the apparatus further includes: The processing module is used to process the input data through the target layer Transformer in the preset lightweight neural network model to obtain the first token feature sequence. The preset lightweight neural network model includes a preset Transformer sub-model, which is a multi-layer structure. Each layer Transformer has a token pruning sub-model integrated at its output. The target layer Transformer is any layer in the multi-layer structure. The input data is the original data or the token features output by the previous layer Transformer of the target layer.

[0097] In one embodiment, after the step of pruning the first token feature sequence according to the token pruning strategy to obtain the pruned target sequence, the apparatus further includes: The transmission module is used to transmit the target sequence to the next layer Transformer corresponding to the target layer when the target layer Transformer is not the last layer of the preset Transformer sub-model, so that the next layer Transformer can continue to process the target sequence and update the first Token feature sequence. The sending module is used to send the target sequence to the cloud when the target layer Transformer is the last layer of a preset Transformer sub-model, so that the cloud can perform inference on the corresponding task of the current input data based on the pruned target sequence.

[0098] The token trimming device provided in this application, employing the token trimming method in the above embodiments, can solve the technical problem of low token trimming accuracy. Compared with the prior art, the beneficial effects of the token trimming device provided in this application are the same as those of the token trimming method provided in the above embodiments, and other technical features in the token trimming device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0099] This application provides a token trimming device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the token trimming method in Embodiment 1 above.

[0100] The following is for reference. Figure 4The diagram illustrates a structural schematic of a token trimming device suitable for implementing embodiments of this application. The token trimming device in these embodiments may include, but is not limited to, mobile terminals such as mobile phones, tablets, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital televisions and desktop computers. Figure 4 The token trimming device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0101] like Figure 4 As shown, the token clipping device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the token clipping device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the token clipping device to communicate wirelessly or wiredly with other devices to exchange data. While the figures show token clipping devices with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.

[0102] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0103] The token trimming device provided in this application, employing the token trimming method described in the above embodiments, can solve the technical problem of low token trimming accuracy. Compared with the prior art, the beneficial effects of the token trimming device provided in this application are the same as those of the token trimming method provided in the above embodiments, and other technical features of this token trimming device are the same as those disclosed in the previous embodiment method, and will not be repeated here.

[0104] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0105] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0106] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the Token trimming method in the above embodiments.

[0107] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0108] The aforementioned computer-readable storage medium may be included in the token trimming device; or it may exist independently and not be assembled into the token trimming device.

[0109] The aforementioned computer-readable storage medium carries one or more programs that, when executed by the Token trimming device, enable the Token trimming device to have exclusive rights.

[0110] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0111] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0112] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0113] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described token trimming method, thereby solving the technical problem of low token trimming accuracy. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the token trimming method provided in the above embodiments, and will not be repeated here.

[0114] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the Token trimming method described above.

[0115] The computer program product provided in this application can solve the technical problem of low token trimming accuracy. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the token trimming method provided in the above embodiments, and will not be repeated here.

[0116] The above descriptions are merely some embodiments of this application and do not limit the scope of protection of this application. Any equivalent structural transformations made based on the technical concept of this application and the content of this specification and drawings, or direct / indirect applications in other related technical fields, are included within the scope of protection of this application. Furthermore, all acquisition of signals, information, or actions in this application are carried out in compliance with the relevant data protection laws and policies of the country where the application is located, and with authorization from the owner of the corresponding device.

Claims

1. A token trimming method, characterized in that, Applied to edge devices, the method includes: Obtain the first token feature sequence of the model's current output; Based on the first token feature sequence, a token pruning strategy is output through a preset token pruning sub-model. The preset token pruning sub-model is obtained by adversarial training of a preset training model containing the token pruning sub-model based on the similarity relationship between the token features before and after perturbation. The first token feature sequence is pruned according to the token pruning strategy to obtain the pruned target sequence.

2. The method as described in claim 1, characterized in that, The step of outputting a token pruning strategy based on the first token feature sequence and a preset token pruning sub-model includes: The similarity between every two token features in the first token feature sequence is calculated using a preset token clipping sub-model. Each token feature is used as a graph node, and the similarity is used as an edge to construct a target similarity graph; Based on the target similarity graph, the sum of similarity connection weights for each token feature is calculated, and the sum of similarity connection weights is used as the first importance of the token feature. Based on the first importance and the preset pruning rate, output the token pruning strategy.

3. The method as described in claim 1, characterized in that, Before the step of obtaining the first token feature sequence currently output by the model, the method further includes: Obtain the second token feature sequence from the model's historical output; Construct an original similarity graph between every two token features in the second token feature sequence, wherein the original similarity graph is used to characterize the similarity relationship between every two token features in the second token feature sequence; Perturbation noise is applied to the original similarity graph to generate a perturbed similarity graph; Based on the original similarity graph, the perturbed similarity graph, and the target task loss function, the preset training model containing the Token pruning sub-model is subjected to adversarial training to obtain the preset Token pruning sub-model.

4. The method as described in claim 3, characterized in that, The step of performing adversarial training on a preset training model containing a token pruning sub-model based on the original similarity graph, the perturbed similarity graph, and the target task loss function to obtain the preset token pruning model includes: The second importance of the token feature is obtained by calculating the sum of the similarity connection weights between each token feature and other features in the original similarity graph. Sort the items according to the second importance to obtain an importance list; Based on the preset clipping rate, the redundant tokens and tokens to be retained in the importance list are determined by a differentiable sampling strategy algorithm. Based on the redundant tokens and the tokens to be retained, the target task loss is calculated using the target task loss function. Based on the perturbation-induced relationship graph and the target task loss, adversarial training is performed on the preset training model containing the Token pruning sub-model to obtain the preset Token pruning model.

5. The method as described in claim 4, characterized in that, The step of performing adversarial training on a preset training model containing a token pruning sub-model based on the perturbated relationship graph and the target task loss to obtain the preset token pruning model includes: The gradients of the target task loss with respect to the original similarity graph and the perturbated similarity graph are calculated, respectively, to obtain the original gradient matrix and the perturbated gradient matrix. The gradient matrix is ​​used to reflect the sensitivity of the model to the similarity relationship between tokens. Based on the original gradient matrix and the perturbed gradient matrix, a consistency constraint loss is constructed, wherein the preset consistency constraint loss is used to maintain the consistency of the model's judgment on the importance of the token under the similarity graph and the perturbed graph; Based on the target task loss and consistency constraint loss, the model parameters of the preset training model are iteratively optimized using gradient descent until a preset lightweight neural network model containing the preset token pruning sub-model is obtained that meets the preset conditions.

6. The method as described in claim 1, characterized in that, Before the step of obtaining the first token feature sequence currently output by the model, the method further includes: The input data is processed by the target layer Transformer in the preset lightweight neural network model to obtain the first token feature sequence. The preset lightweight neural network model includes a preset Transformer sub-model, which is a multi-layer structure. Each layer Transformer has a token pruning sub-model integrated at its output. The target layer Transformer is any layer in the multi-layer structure. The input data is the original data or the token features output by the previous layer Transformer corresponding to the target layer.

7. The method as described in claim 6, characterized in that, After the step of pruning the first token feature sequence according to the token pruning strategy to obtain the pruned target sequence, the method further includes: When the target layer Transformer is not the last layer of the preset Transformer sub-model, the target sequence is passed to the next layer Transformer corresponding to the target layer, so that the next layer Transformer can continue to process the target sequence and update the first Token feature sequence. When the target Transformer is the last layer of the preset Transformer sub-model, the target sequence is sent to the cloud so that the cloud can perform inference on the corresponding task of the current input data based on the pruned target sequence.

8. A token cutting device, characterized in that, The device includes: The first acquisition module is used to acquire the first token feature sequence currently output by the model; The model processing module is used to output a token pruning strategy based on the first token feature sequence through a preset token pruning sub-model. The preset token pruning sub-model is obtained by adversarial training of a preset training model containing the token pruning sub-model based on the similarity relationship between the token features before and after perturbation. The pruning module is used to prune the first token feature sequence according to the token pruning strategy to obtain the pruned target sequence.

9. A token cutting device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the token trimming method as described in any one of claims 1 to 7.

10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the Token trimming method as described in any one of claims 1 to 7.

11. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the steps of the Token trimming method as described in any one of claims 1 to 7.