A method and system for cross-device data collaborative training of LoRa role models based on H2O
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-21
- Publication Date
- 2026-08-14
AI Technical Summary
[0003]现有技术中,跨设备协同训练面临终端设备显存和算力极度受限的技术瓶颈,传统的LoRA微调在处理长对话时极易导致终端内存溢出
[0049] This invention provides a cross-device data collaborative training method and system for LoRa role models based on H2O. By deeply coupling the H2O dynamic caching mechanism for role semantic awareness with LoRa fine-tuning and federated learning, it effectively overcomes the bottleneck of edge hardware memory. While ensuring the immutability of core setting data, it achieves low-cost local computation for long text interactions and utilizes local feature distribution variance and cache retention rate as physical quantitative constraints for underlying fine-tuning and global weighted aggregation, significantly improving the security of cross-device model parameter evolution and the consistency of role semantics across the entire network.
Smart Images

Figure CN122572575A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of data processing, and in particular relates to a cross-device data collaborative training method and system for LoRa role models based on H2O. Background Technology
[0002] With the popularization of large language models, role-playing models have attracted widespread attention due to their highly anthropomorphic and personalized interactive experience. To protect user privacy and achieve personalized character settings tailored to each user, the industry is gradually adopting low-rank fine-tuning (LoRA) technology for cross-device collaborative training on user terminals. During long-term role-playing interactions, the model needs to incorporate a large amount of historical dialogue context, requiring the maintenance of a massive key-value cache during the inference and training phases to ensure the consistency of character settings.
[0003] In existing technologies, cross-device collaborative training faces the technical bottleneck of extremely limited terminal device memory and computing power. Traditional LoRA fine-tuning is prone to causing terminal memory overflow when processing long dialogues. Although existing solutions attempt to introduce conventional context truncation or uniform sparsity cache compression techniques, these solutions often blindly remove feature words containing core character traits and key memories when applied to character models, severely damaging the consistency and logical coherence of character semantics. At the same time, the heterogeneity of data between different devices means that simple local cache compression can cause feature shifts during global gradient aggregation. Existing technologies lack an efficient collaborative fine-tuning mechanism that can balance terminal memory limitations, global character semantic consistency, and cross-device communication efficiency. Summary of the Invention
[0004] The purpose of this invention is to provide a cross-device data collaborative training method and system for LoRa role models based on H2O, aiming to solve the problems mentioned in the background art.
[0005] This invention is implemented as follows: On one hand, a cross-device data collaborative training method for LoRa role models based on H2O, the method comprising:
[0006] On various terminal devices, a dynamic H2O mechanism combining role semantic weights is used to perform local feature filtering on role interaction text and build a lightweight context cache that locks the role anchor point.
[0007] The forward propagation of the local LoRA network is performed based on the lightweight context cache, and the LoRA feature scaling coefficient is dynamically calculated according to the attention distribution of heavy words selected by the dynamic H2O mechanism, thereby generating the local role constraint gradient.
[0008] Perform cross-device secure synchronization of the local role constraint gradients of each terminal device, and extract the H2O cache retention rate of each terminal device as an adaptive weight factor on the central server, perform weighted aggregation on the local role constraint gradients, and generate a global aggregated gradient.
[0009] The central server updates the global LoRA model parameters based on the global aggregated gradient and distributes the updated global LoRA model parameters to each terminal device for local synchronization.
[0010] As a further aspect of the present invention, the step of using a dynamic H2O mechanism that combines role semantic weights to perform local feature filtering on role interaction text on various terminal devices and constructing a lightweight context cache that locks role anchor points specifically includes:
[0011] The system analyzes the local interactive text generated by the terminal device, extracts the static character setting text and the dynamic multi-turn dialogue text, and converts them into word sequence sequences to be input into the pre-trained large language model.
[0012] Assign absolute retention weights to the lexical units corresponding to the character setting text, and lock them in the local key-value cache as anchor points of the character that do not participate in dynamic elimination;
[0013] In the attention calculation stage of the pre-trained large language model, the standard attention score of the corresponding word unit of the multi-turn dialogue text is multiplied by the pre-calculated role semantic similarity to generate a biased role perception attention score.
[0014] Based on the character perception attention score, the dynamic H2O mechanism is executed, retaining the highest-scoring heavy word and the latest local window word, eliminating irrelevant words, and generating the lightweight context cache to release local video memory.
[0015] As a further aspect of the present invention, the step of performing forward propagation of the local LoRA network based on the lightweight context cache, and dynamically calculating the LoRA feature scaling coefficient according to the attention distribution of heavy lexical units selected by the dynamic H2O mechanism, and generating the local role constraint gradient accordingly, specifically includes:
[0016] The first reduced-dimensional matrix and the second increased-dimensional matrix of the local LoRA to be trained are injected by the bypass into the Transformer layer of the local pre-trained large language model to construct the local LoRA network, and the lightweight context cache is used as input for forward propagation prediction.
[0017] Extract the attention variance of the currently participating heavy word units, and dynamically calculate the corresponding LoRA feature scaling factor accordingly;
[0018] The feature output of the local LoRA network is adaptively weighted using the LoRA feature scaling coefficient, and then added and fused with the base output of the pre-trained large language model;
[0019] By combining the prediction results with real interaction data, a loss function containing role constraint penalty terms is calculated. Backpropagation is then performed, updating only the parameters of the first reduced-dimensional matrix and the second increased-dimensional matrix of the local LoRA, thereby generating the local role constraint gradient.
[0020] As a further aspect of the present invention, the step of performing cross-device secure synchronization of the local role constraint gradients of each terminal device, extracting the H2O cache retention rate of each terminal device as an adaptive weight factor on the central server, and performing weighted aggregation on the local role constraint gradients to generate a global aggregated gradient specifically includes:
[0021] Each terminal device calculates the average cache retention rate of its local dynamic H2O mechanism during the current training cycle and generates the corresponding H2O cache retention rate.
[0022] The local role constraint gradient is quantized, compressed, and subjected to differential privacy encryption to generate a ciphertext gradient.
[0023] Each terminal device uploads the encrypted gradient along with the H2O cache retention rate to the central server via a secure link;
[0024] After the central server decrypts the encrypted gradient, it normalizes the H2O cache retention rate of each terminal device into the adaptive weight factor and executes the federated adaptive weighted average algorithm to generate the global aggregate gradient.
[0025] As a further aspect of the present invention, the central server updates the global LoRA model parameters based on the global aggregated gradient, and distributes the updated global LoRA model parameters to each terminal device for local synchronization, specifically including:
[0026] The central server uses the optimizer to apply the global aggregated gradient to the global LoRA model parameters, completing one round of iterative update of the global role model;
[0027] The updated global role model is inferred using the standard role evaluation validation set to calculate role feature offsets;
[0028] If the character feature offset is lower than the preset security consistency threshold, then calculate the parameter difference between the current global LoRA model parameters and the parameters of the previous round;
[0029] The parameter difference values are then sent to all terminal devices participating in this round of collaborative training.
[0030] The terminal device receives the parameter difference and merges the corresponding elements with the parameters of the existing local LoRA network to complete local synchronization.
[0031] As a further aspect of the present invention, another option is a cross-device data collaborative training system for LoRa role models based on H2O, the system comprising:
[0032] The role-aware cache optimization module is used to perform local feature filtering on the role interaction text on the terminal device by using a dynamic H2O mechanism that combines role semantic weights, and to build a lightweight context cache that locks the role anchor point.
[0033] The dynamic feature scaling gradient calculation module is used to perform forward propagation of the local LoRA network based on the lightweight context cache, and dynamically calculate the LoRA feature scaling coefficient according to the attention distribution of heavy words selected by the dynamic H2O mechanism, thereby generating the local role constraint gradient.
[0034] The aggregation module based on cache retention rate is used to perform cross-device secure synchronization of the local role constraint gradients of each terminal device, and extract the H2O cache retention rate of each terminal device as an adaptive weight factor on the central server side, and perform weighted aggregation on the local role constraint gradients to generate a global aggregated gradient.
[0035] The global parameter evolution and synchronization module is used to update the global LoRA model parameters on the central server based on the global aggregated gradient, and to distribute the updated global LoRA model parameters to each terminal device for local synchronization.
[0036] As a further aspect of the present invention, the role-aware cache optimization module specifically includes:
[0037] The text parsing and stripping unit is used to strip static character setting text and dynamic multi-turn dialogue text and convert them into word sequence;
[0038] Anchor point locking unit is used to assign an absolute retention weight to the character setting text and lock it in the local key-value cache;
[0039] The perception score generation unit is used to fuse the standard attention score with the character's semantic similarity to generate the character's perception attention score;
[0040] The dynamic cache eviction unit is used to generate the lightweight context cache by executing an eviction mechanism based on the role perception attention score.
[0041] As a further aspect of the present invention, the dynamic feature scaling gradient calculation module specifically includes:
[0042] The network bypass injection unit is used to inject the local LoRA dimensionality reduction matrix A and the dimensionality increase matrix B to construct the local LoRA network and perform forward prediction.
[0043] The scaling factor derivation unit is used to extract the attention variance of heavy words to generate the LoRA feature scaling factor;
[0044] An adaptive weighted fusion unit is used to weight the feature output using the scaling coefficient and fuse it with the base output;
[0045] A constraint backpropagation unit is used to calculate the loss function and update the parameters to generate the local role constraint gradient.
[0046] As a further aspect of the present invention, the aggregation module based on cache retention rate specifically includes:
[0047] The retention rate statistics unit is used to count and generate the local H2O cache retention rate; the encryption and desensitization unit is used to quantize and encrypt the local role constraint gradient to generate ciphertext gradient; the secure transmission unit is used to upload the ciphertext gradient and the H2O cache retention rate to the central server.
[0048] The decryption and weighted aggregation unit is used to decrypt the ciphertext and normalize the H2O cache retention rate into weight factors, ultimately generating the global aggregated gradient.
[0049] This invention provides a cross-device data collaborative training method and system for LoRa role models based on H2O. By deeply coupling the H2O dynamic caching mechanism for role semantic awareness with LoRa fine-tuning and federated learning, it effectively overcomes the bottleneck of edge hardware memory. While ensuring the immutability of core setting data, it achieves low-cost local computation for long text interactions and utilizes local feature distribution variance and cache retention rate as physical quantitative constraints for underlying fine-tuning and global weighted aggregation, significantly improving the security of cross-device model parameter evolution and the consistency of role semantics across the entire network. Attached Figure Description
[0050] Figure 1 This is the main flowchart of a cross-device data collaborative training method for LoRa role models based on H2O.
[0051] Figure 2 This is a flowchart illustrating a cross-device data collaborative training method for LoRa role models based on H2O. It describes how the forward propagation of a local LoRA network is performed using a lightweight context cache, and how LoRA feature scaling coefficients are dynamically calculated based on the attention distribution of heavy lexical units selected by the dynamic H2O mechanism to generate local role constraint gradients.
[0052] Figure 3This is a flowchart illustrating a cross-device data collaborative training method for LoRa role models based on H2O. It describes the secure synchronization of local role constraint gradients across various terminal devices, and the extraction of H2O cache retention rates from each terminal device as adaptive weighting factors on a central server to perform weighted aggregation of the local role constraint gradients to generate a global aggregated gradient.
[0053] Figure 4 This is a flowchart illustrating a cross-device data collaborative training method for LoRa role models based on H2O, in which the central server updates the global LoRa model parameters based on the global aggregated gradient and distributes the updated global LoRa model parameters to each terminal device for local synchronization.
[0054] Figure 5 This is the main structure diagram of a cross-device data collaborative training system for LoRa role models based on H2O.
[0055] Figure 6 This is a structural block diagram of a role perception cache optimization module in a LoRa role model cross-device data collaborative training system based on H2O.
[0056] Figure 7 This is a block diagram of the dynamic feature scaling gradient calculation module in a cross-device data collaborative training system for LoRa role models based on H2O.
[0057] Figure 8 This is a structural diagram of an aggregation module based on cache retention rate in a LoRa role model cross-device data collaborative training system based on H2O. Detailed Implementation
[0058] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0059] The specific implementation of the present invention will be described in detail below with reference to specific embodiments.
[0060] This invention provides a cross-device data collaborative training method and system for LoRa role models based on H2O, which solves the technical problems in the background art.
[0061] like Figure 1 The diagram shown is a main flowchart of a cross-device data collaborative training method for LoRa role models based on H2O, provided as an embodiment of the present invention. The method includes:
[0062] Step S100: On each terminal device, use the dynamic H2O mechanism that combines role semantic weights to perform local feature filtering on the role interaction text and build a lightweight context cache that locks the role anchor point.
[0063] Step S200: Perform forward propagation of the local LoRA network based on the lightweight context cache, and dynamically calculate the LoRA feature scaling coefficient according to the attention distribution of heavy lexical units selected by the dynamic H2O mechanism, thereby generating the local role constraint gradient.
[0064] Step S300: Perform cross-device secure synchronization of the local role constraint gradients of each terminal device, and extract the H2O cache retention rate of each terminal device as an adaptive weight factor on the central server, perform weighted aggregation on the local role constraint gradients, and generate a global aggregated gradient;
[0065] Step S400: The central server updates the global LoRA model parameters based on the global aggregated gradient and sends the updated global LoRA model parameters to each terminal device for local synchronization;
[0066] In this embodiment, when a user initiates a role-based interaction on the terminal side, the system's underlying daemon process first triggers a step of using a dynamic H2O mechanism that combines role semantic weights to perform local feature filtering on the role interaction text and construct a lightweight context cache. By intervening in the key-value cache allocation mechanism of the standard transformer model architecture, the H2O oracle is dynamically adjusted using role semantic weights. Uncoverable role anchors are hard-locked in the memory pool, while redundant historical conversation terms with low information entropy are eliminated, thereby opening up a highly refined lightweight context cache area in physical memory. Next, the process proceeds to the step of performing forward propagation of a local LoRA network based on the lightweight context cache and dynamically calculating feature scaling coefficients to generate local role constraint gradients. The underlying deep learning computation graph engine loads this lightweight cache and performs forward computation of the LoRA network, reading the heavy term attention distribution features filtered by the H2O mechanism in real time, and dynamically generating feature scaling coefficients using their statistical variance. This directly intervenes in the local gradient differentiation process, forcing the gradient update direction to converge to the current role's personality traits. After completing multiple rounds of local iteration, the process proceeds to the step of cross-device secure synchronization of local role constraint gradients and extracting the cache retention rate as an adaptive weight factor for weighted aggregation on the central server. Terminal devices do not transmit the original plaintext interactions; instead, they perform homomorphic encryption or differential privacy noise enhancement on the local gradients containing role constraints. This is then encapsulated with the H2O cache retention rate of the current cycle into a structured network data packet, which is synchronized to the central server via a transport layer secure protocol communication link. Within a trusted execution environment, the central server extracts the unpacked cache retention rate as an adaptive weight factor characterizing the data quality at the edge, and performs asymmetric weighted aggregation. Finally, in the step where the central server updates the model parameters based on the global aggregated gradient and distributes them to the terminal devices for local synchronization, the central server uses optimizers such as adaptive moment estimation and weight decay to write the global gradient into the global LoRA parameter pool. After verifying that the model has not experienced catastrophic role forgetting, it extracts the tensor difference before and after the update and distributes it to each terminal using a spatial download technology protocol. The terminal's memory controller directly performs tensor element addition and merging in the GPU memory without unloading the base model, completing a seamless evolution of edge-side AI capabilities.
[0067] As a preferred embodiment of the present invention, the step of using a dynamic H2O mechanism that combines role semantic weights to perform local feature filtering on role interaction text and constructing a lightweight context cache that locks role anchor points on various terminal devices specifically includes:
[0068] Step S101: Analyze the local interactive text generated by the terminal device, extract the static character setting text and the dynamic multi-turn dialogue text, and convert them into word sequence inputs into the pre-trained large language model;
[0069] Step S102: Assign absolute retention weights to the lexical units corresponding to the character setting text, and lock them in the local key-value cache as the character anchor points that do not participate in dynamic elimination;
[0070] Step S103: In the attention calculation stage of the pre-trained large language model, the standard attention score of the corresponding word unit of the multi-turn dialogue text is multiplied by the pre-calculated role semantic similarity to generate a biased role perception attention score.
[0071] Step S104: Execute the dynamic H2O mechanism based on the character perception attention score, retain the highest-scoring heavy word and the latest local window word, eliminate irrelevant words, and generate the lightweight context cache to release local video memory.
[0072] In this embodiment, when the terminal receives a text stream input by the user, the local word segmenter first uses regular expressions or fixed identifiers to separate the text into static character setting text and dynamic multi-turn dialogue text at the abstract syntax tree level. Then, when assigning absolute retention weights to the character setting text and locking it as a character anchor, the elimination weight of the corresponding character in the static character setting text is forcibly set to zero when allocating key-value cache memory blocks for the lexical sequence. It is marked as a permanently resident node in the underlying linked list structure, ensuring that this tensor never participates in the H2O elimination queue regardless of how the context window slides. For multi-turn dialogue text, when generating a character-aware attention score by fusing the standard attention score and character semantic similarity, not only is the inner product of the query matrix and key matrix calculated to obtain the standard attention score, but a lightweight word embedding cosine similarity calculation unit is also called in parallel to calculate the semantic similarity between the current lexical feature vector and the character anchor feature vector. Then, the two are multiplied arithmetically to output the fused character-aware attention score. Finally, when executing the step of using the dynamic H2O mechanism based on the role perception attention score to generate a lightweight context cache, the underlying layer calls a greedy elimination algorithm to perform memory reclamation and release operations on the tensor blocks in the key-value cache according to the role perception attention score from low to high. Only the heavy words ranked at the top of the score and a few of the latest local window words are retained to maintain basic grammatical fluency. In the end, a lightweight context cache with high information density and strong role association is built in the limited video memory space of the terminal.
[0073] like Figure 2 As shown, in a preferred embodiment of the present invention, the step of performing forward propagation of the local LoRA network based on the lightweight context cache, and dynamically calculating the LoRA feature scaling coefficient according to the attention distribution of heavy lexical units selected by the dynamic H2O mechanism, and generating the local role constraint gradient accordingly, specifically includes:
[0074] Step S201: Inject the first reduced-dimensional matrix and the second increased-dimensional matrix of the local LoRA to be trained into the Transformer layer of the local pre-trained large language model to construct the local LoRA network, and use the lightweight context cache as input for forward propagation prediction;
[0075] Step S202: Extract the attention variance of the currently participating heavy word units, and dynamically calculate the corresponding LoRA feature scaling coefficient accordingly;
[0076] Step S203: Adaptively weight the feature output of the local LoRA network using the LoRA feature scaling coefficient, and then add and fuse it with the base output of the pre-trained large language model;
[0077] Step S204: Combine the prediction results with the real interaction data to calculate the loss function containing the role constraint penalty term, perform backpropagation, update only the parameters of the local LoRA first dimension reduction matrix and the second dimension increase matrix, and generate the local role constraint gradient.
[0078] In this embodiment, the computation graph of the critical self-attention calculation module in the pre-trained large language model is bypassed. The local LoRA first-dimensionality reduction matrix and second-dimensionality increase matrix are injected via memory pointers. The generated lightweight context cache tensor is loaded into GPU memory as network input for forward propagation prediction. When performing the step of extracting the attention variance of heavy lexical units and dynamically deriving the LoRA feature scaling coefficients, to establish the mathematical coupling between the memory cleanup mechanism and the fine-tuning mechanism, the system's monitoring thread extracts the attention score set composed of heavy lexical units filtered by the H2O mechanism within the current period and calculates the variance. The larger the variance, the more concentrated the role information distribution of the current context. At this time, the system substitutes this variance value into the preset S-shaped logical mapping function to dynamically calculate the LoRA feature scaling coefficients for the current inference step. When performing the adaptive weighted fusion of local LoRA feature outputs using LoRA feature scaling factors, the computation unit passes the input feature vector through the base backbone network and the LoRA bypass network respectively. For the output tensor of the LoRA bypass, it multiplies element-wise by the dynamically calculated feature scaling factor. Then, it performs matrix addition on the weighted LoRA feature tensor and the feature tensor output by the base network. When calculating the loss function containing the role constraint penalty term and performing backpropagation to generate local role constraint gradients, in addition to using the standard cross-entropy loss function, the calculation of the loss function also introduces a role constraint penalty term to calculate the relative entropy between the current output and the role anchor point. The computation engine performs automatic differentiation based on this composite loss function, freezes the gradient properties of all base backbone networks in the computation graph, and only calculates the partial derivatives with respect to the elements of the first dimensionality reduction matrix and the second dimensionality increase matrix, thereby generating a small-volume but deeply meaningful local role constraint gradient tensor containing specific character personality logic.
[0079] like Figure 3 As shown, in a preferred embodiment of the present invention, the process of performing cross-device secure synchronization of the local role constraint gradients of each terminal device, extracting the H2O cache retention rate of each terminal device as an adaptive weight factor on the central server, and performing weighted aggregation on the local role constraint gradients to generate a global aggregated gradient specifically includes:
[0080] Step S301: Each terminal device calculates the average cache retention rate of the local dynamic H2O mechanism in the current training cycle and generates the corresponding H2O cache retention rate;
[0081] Step S302: Quantize and compress the local role constraint gradient and perform differential privacy encryption to generate ciphertext gradient;
[0082] Step S303: After the central server decrypts the encrypted gradient, it normalizes the H2O cache retention rate of each terminal device into the adaptive weight factor and executes the federated adaptive weighted average algorithm to generate the global aggregate gradient.
[0083] It should be understood that the background daemon of each participating terminal device is configured with a state counter. In each complete local training round, it accumulates the total number of tokens input to the large model and the number of tokens that remain in the key-value cache after being filtered by the dynamic H2O mechanism. Based on this, the ratio is calculated as the local H2O cache retention rate. This retention rate reflects the concentration ratio of high-value role corpus in the local interaction data of the terminal at the physical level. Subsequently, when performing the steps of quantizing and compressing the local role constraint gradient and generating ciphertext gradients using differential privacy encryption, in order to defend against model reverse attacks, the terminal security module first quantizes and reduces the dimensionality of the generated local role constraint gradient tensor using a low-precision format (such as an eight-bit integer), and then uses a Gaussian mechanism to inject a random noise matrix that satisfies the differential privacy parameters into the gradient matrix to generate anonymized ciphertext gradients. When uploading the encrypted gradient and H2O cache retention rate to the central server via a secure link, the terminal calls the network socket at the operating system's underlying level to establish an encrypted tunnel based on the transport layer security protocol. The encrypted gradient and H2O cache retention rate are then encapsulated, serialized, and uploaded to the central server's receiving buffer. When decrypting the encrypted gradient and normalizing the H2O cache retention rate as a weighting factor for federated adaptive weighted averaging, the central server cluster performs inverse quantization decryption in parallel within the graphics processor's memory. Unlike traditional federated averaging algorithms that crudely average by the number of terminals, the central aggregation node extracts the set of H2O cache retention rates reported by each device, performs global normalization using a normalized exponential function, and uses the normalized retention rate as the adaptive weighting factor for each device's gradient. Finally, a tensor-level weighted summation is performed. Because the gradient of devices with high retention rates has an automatically amplified decision weight in the aggregation, a high-quality, feature-biased global aggregated gradient is generated.
[0084] like Figure 4 As shown, in a preferred embodiment of the present invention, the central server updates the global LoRA model parameters based on the global aggregated gradient and distributes the updated global LoRA model parameters to each terminal device for local synchronization, specifically including:
[0085] Step S401: The central server uses the optimizer to apply the global aggregated gradient to the global LoRA model parameters, completing one round of iterative update of the global role model;
[0086] Step S402: Use the standard role evaluation validation set to infer the updated global role model and calculate the role feature offset;
[0087] Step S403: If the role feature offset is lower than the preset security consistency threshold, calculate the parameter difference between the current global LoRA model parameters and the parameters of the previous round;
[0088] Step S404: Send the parameter difference to all terminal devices participating in this round of collaborative training;
[0089] Step S405: The terminal device receives the parameter difference and merges the corresponding elements with the parameters of the existing local LoRA network to complete local synchronization;
[0090] In this embodiment, during the step of applying the global aggregated gradient to the global LoRA model parameters using the optimizer to complete the iterative update, the parameter server node of the central server maintains the full parameter state of the global large model in its GPU memory. Once the global aggregated gradient is generated, the system calls the adaptive moment estimation optimizer component and applies the update direction of the global aggregated gradient to the global LoRA model parameter matrix according to the configured learning rate, completing the mathematical iteration of parameters in the cloud. To prevent role collapse caused by malicious node poisoning during federated learning, when performing the step of calculating role feature offsets using the standard role evaluation validation set, the server automatically triggers an automated evaluation pipeline. This pipeline loads the pre-set standard role evaluation validation set to drive the updated global model for inference. By calculating the perplexity of the generated text and the semantic offset from the baseline model output, the role feature offset is quantified. When performing the steps of determining the role feature offset and calculating the global LoRA model parameter difference, the system's microservice decision module compares the offset with a security consistency threshold. If it is lower than the threshold, the server's tensor calculation unit subtracts the previous round's parameter matrix from the current iteration's global LoRA parameter matrix to extract the absolute parameter difference tensor, thereby minimizing downlink bandwidth consumption. When sending the parameter difference to the terminal device, the cloud content delivery network or distributed message queue system packages the serialized parameter difference into a lightweight upgrade patch and multicasts it to the edge terminal devices that participated in this round of training. Finally, when the terminal device receives the parameter difference and merges it with the local LoRA network parameters for synchronization, the terminal device's underlying model hot update module intercepts memory access requests and directly performs element-wise addition between the received difference tensor and the existing local LoRA network tensor in the video memory, completing the local AI model synchronization upgrade without the user's awareness.
[0091] like Figure 5As shown, in another preferred embodiment of the present invention, a cross-device data collaborative training system for LoRa role models based on H2O is provided, the system comprising:
[0092] The role-aware cache optimization module 100 is used to perform local feature filtering on the role interaction text on the terminal device by using a dynamic H2O mechanism that combines role semantic weights, and to build a lightweight context cache that locks the role anchor point.
[0093] The dynamic feature scaling gradient calculation module 200 is used to perform forward propagation of the local LoRA network based on the lightweight context cache, and dynamically calculate the LoRA feature scaling coefficient according to the attention distribution of heavy words selected by the dynamic H2O mechanism, thereby generating the local role constraint gradient.
[0094] The aggregation module 300 based on cache retention rate is used to perform cross-device secure synchronization of the local role constraint gradients of each terminal device, and extract the H2O cache retention rate of each terminal device as an adaptive weight factor on the central server, perform weighted aggregation on the local role constraint gradients, and generate a global aggregated gradient.
[0095] The global parameter evolution and synchronization module 400 is used to update the global LoRA model parameters on the central server based on the global aggregated gradient, and to distribute the updated global LoRA model parameters to each terminal device for local synchronization.
[0096] In this embodiment, the role-aware cache optimization module 100, instantiated within the client engine, directly intervenes in the underlying logic of the large-scale model's allocation and release of key-value cache blocks in random access memory by calling the memory controller of the terminal device's central processing unit or neural network processor. The dynamic feature scaling gradient calculation module 200, relying on the tensor calculation core of the terminal device's mobile graphics processor, calculates the scaling scalar while processing the local dialogue stream and derives a temporary fine-tuning gradient tensor in video memory. Simultaneously, the system is bridged to a server cluster deployed in a cloud data center via a wide area network. The cache retention rate-based aggregation module 300 in the client engine initiates encrypted data stream transmission to the cloud using the terminal's network interface card. The cloud data center is equipped with a large-scale graphics processor computing array and high-speed solid-state drive storage devices to support the core processing logic. By parsing the cache retention rate scalar in the data packets, it completes the decryption and weighted normalization summation of the terabyte-level encrypted gradient matrix within the graphics card cluster. Finally, under the scheduling of the cloud master node, the global parameter evolution and synchronization module 400 updates the global model copy stored in the main memory, generates incremental parameter packages, and then reverse-synchronizes them back to the local storage medium of all network terminals.
[0097] like Figure 6As shown, in another preferred embodiment of the present invention, the role perception cache optimization module 100 specifically includes:
[0098] The text parsing and stripping unit 101 is used to strip static character setting text and dynamic multi-turn dialogue text and convert them into word sequence;
[0099] Anchor point locking unit 102 is used to assign an absolute retention weight to the character setting text and lock it in the local key-value cache;
[0100] The perception score generation unit 103 is used to fuse the standard attention score and the character semantic similarity to generate the character perception attention score;
[0101] The dynamic cache eviction unit 104 is used to generate the lightweight context cache by executing an eviction mechanism based on the role perception attention score.
[0102] In this embodiment, the text parsing and stripping unit 101, acting as the input front-end, is deployed as a multi-threaded text processing process residing in the terminal's main memory. When it receives corpus from the upper-layer user interface, it uses a byte-to-byte encoding tool to cut it and physically splits it into static character settings and dynamic multi-turn dialogue blocks in memory space according to delimiters. Subsequently, the anchor locking unit 102 takes over memory scheduling authority, calls the application programming interface at the underlying memory allocation level, forcibly loads the character setting lexical matrix into the protected high-order address range of memory, and modifies its attributes in the memory page table to be read-only and non-replaceable, forming an absolute anchor in the locked cache. Next, during the forward inference of the large model, the perception score generation unit 103 runs synchronously in the terminal matrix multiplication accelerator. This unit includes a dedicated cosine similarity calculation operator, establishes a bypass outside the conventional attention weight matrix calculation, captures latent vector representations in real time to calculate the similarity scalar, and then multiplies the scalar by the standard attention score to output the character perception attention score and stores it in a temporary register. Finally, the dynamic cache eviction unit 104, as the execution mechanism for memory garbage collection, is periodically woken up by a background asynchronous daemon thread. It reads the register array and executes the quicksort algorithm to identify the tail data, and then sends a video memory release instruction to the operating system's memory management unit to mark the redundant word memory block as available.
[0103] like Figure 7 As shown, in another preferred embodiment of the present invention, the dynamic feature scaling gradient calculation module 200 specifically includes:
[0104] The network bypass injection unit 201 is used to inject the local LoRA dimensionality reduction matrix A and the dimensionality increase matrix B to construct the local LoRA network and perform forward prediction.
[0105] The scaling factor derivation unit 202 is used to extract the attention variance of heavy words to generate the LoRA feature scaling factor;
[0106] The adaptive weighted fusion unit 203 is used to weight the feature output using the scaling coefficient and fuse it with the base output;
[0107] The constraint backpropagation unit 204 is used to calculate the loss function and update the parameters to generate the local role constraint gradient.
[0108] In this embodiment, during the initialization phase, the network bypass injection unit 201 parses and modifies the local open neural network exchange format model file, instantiating parameter tensors representing the first reduced-dimensional matrix and the second increased-dimensional matrix of the local LoRA next to the standard linear layer nodes. These tensors, along with the lightweight context cache, are scheduled into the L1 or L2 cache of the graphics processor. During the inference clock cycle, the scaling factor derivation unit 202 allocates a temporary array in main memory, collects the attention score distribution of heavy terms, and calls the tensor variance calculation library to calculate the variance value in real time. It then uses a pre-compiled sigmoid logic function to convert it into floating-point feature scaling factors and stores them in a dedicated register. Subsequently, the adaptive weighted fusion unit 203 uses a broadcast mechanism to perform element-wise fusion multiplication and addition instructions on the coefficients in the register and the LoRA bypass activation value tensor, and accumulates them with the base network feature tensor to complete feature fusion. When entering the backpropagation phase, the constrained backpropagation unit 204 calls the loss function operator, compares the predicted output with the real sequence, introduces the penalty operator for calculating relative entropy to generate the total loss scalar; then the automatic differentiation engine reverses the chain rule to calculate the derivative, generates the partial derivative tensors with respect to the first dimension reduction matrix and the second dimension increase matrix, and uses the stochastic gradient descent optimizer to update the parameters in-place in the GPU memory.
[0109] like Figure 8 As shown, in another preferred embodiment of the present invention, the aggregation module 300 based on cache retention rate specifically includes:
[0110] The retention rate statistics unit 301 is used to count and generate the local H2O cache retention rate; the encryption and desensitization unit 302 is used to quantize and encrypt the local role constraint gradient to generate a ciphertext gradient; the secure transmission unit 303 is used to upload the ciphertext gradient and the H2O cache retention rate to the central server.
[0111] The decryption and weighted aggregation unit 304 is used to decrypt the ciphertext and normalize the H2O cache retention rate into a weight factor, and finally generate the global aggregation gradient.
[0112] In this embodiment, during application, on the terminal device side, the retention rate statistics unit 301 operates as a system-level background counting service. After the model completes one round of fine-tuning, it reads the historical audit logs of the memory pool allocation table, divides the number of retained tokens by the total number of tokens to calculate the cache retention rate scalar, and stores it in the pending queue. Subsequently, the encryption and desensitization unit 302 calls the high-level single-instruction multiple-data instruction set of the central processing unit to compress the high-precision tensor of the single-precision floating-point number into an eight-bit integer format. Then, it calls the terminal's built-in security chip to use the public key to apply Laplace noise using a differential privacy algorithm in the trusted execution area to generate a ciphertext gradient. Next, the secure transmission unit 303 establishes a secure tunnel based on the Hypertext Transfer Protocol (HTTP) between the terminal and the central server gateway through the transmission control protocol stack and sends the data in packages. On the cloud data center side, the decryption and weighted aggregation unit 304 is deployed on a high-performance computing node, using the private key in the secure memory area to decrypt the ciphertext gradient in parallel. At the same time, the coprocessor extracts the retention rate scalar array reported by the device, performs normalization operations to generate a weight factor array, and finally calls the underlying collection communication and computing library to perform reduction addition and averaging operations on the tensors of thousands of terminals according to the weight factors, and finally solidifies and outputs a highly convergent global aggregated gradient matrix tensor in memory.
[0113] The above embodiments of the present invention provide a cross-device data collaborative training method for LoRa role models based on H2O, and a cross-device data collaborative training system for LoRa role models based on H2O. By deeply coupling the H2O dynamic caching mechanism for role semantic awareness with LoRa fine-tuning and federated learning, the bottleneck of edge hardware memory is effectively overcome. While ensuring the immutability of core setting data, local low-cost computation for long text interactions is achieved. Furthermore, the local feature distribution variance and cache retention rate are used as physical quantitative constraints for underlying fine-tuning and global weighted aggregation, significantly improving the security of cross-device model parameter evolution and the consistency of role semantics across the entire network.
[0114] In order for the above methods and systems to operate smoothly, the system may include more or fewer components than those described above, or combine certain components, or different components, in addition to the various modules mentioned above. For example, it may include input / output devices, network access devices, buses, processors, and memory.
[0115] The processor can be a central processing unit, or other general-purpose processors, digital signal processors, application-specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (OPGs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. This processor is the control center of the system, connecting various parts via various interfaces and lines.
[0116] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0117] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of this patent should be determined by the appended claims.
[0118] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A cross-device data collaborative training method for LoRa role models based on H2O, characterized in that, The method includes: On various terminal devices, a dynamic H2O mechanism combining role semantic weights is used to perform local feature filtering on role interaction text and build a lightweight context cache that locks the role anchor point. The forward propagation of the local LoRA network is performed based on the lightweight context cache, and the LoRA feature scaling coefficient is dynamically calculated according to the attention distribution of heavy words selected by the dynamic H2O mechanism, thereby generating the local role constraint gradient. Perform cross-device secure synchronization of the local role constraint gradients of each terminal device, and extract the H2O cache retention rate of each terminal device as an adaptive weight factor on the central server, perform weighted aggregation on the local role constraint gradients, and generate a global aggregated gradient. The central server updates the global LoRA model parameters based on the global aggregated gradient and distributes the updated global LoRA model parameters to each terminal device for local synchronization.
2. The method for cross-device data collaborative training of LoRa role models based on H2O according to claim 1, characterized in that, The process of using a dynamic H2O mechanism that combines role semantic weights to perform local feature filtering on role interaction text and constructing a lightweight context cache that locks role anchor points on various terminal devices specifically includes: The system analyzes the local interactive text generated by the terminal device, extracts the static character setting text and the dynamic multi-turn dialogue text, and converts them into word sequence sequences to be input into the pre-trained large language model. Assign absolute retention weights to the lexical units corresponding to the character setting text, and lock them in the local key-value cache as anchor points of the character that do not participate in dynamic elimination; In the attention calculation stage of the pre-trained large language model, the standard attention score of the corresponding word unit of the multi-turn dialogue text is multiplied by the pre-calculated role semantic similarity to generate a biased role perception attention score. Based on the character perception attention score, the dynamic H2O mechanism is executed, retaining the highest-scoring heavy word and the latest local window word, eliminating irrelevant words, and generating the lightweight context cache to release local video memory.
3. The method for cross-device data collaborative training of LoRa role models based on H2O according to claim 1, characterized in that, The process of performing forward propagation of the local LoRA network based on the lightweight context cache, and dynamically calculating the LoRA feature scaling coefficient according to the attention distribution of heavy lexical units selected by the dynamic H2O mechanism, and generating local role constraint gradients accordingly, specifically includes: The first reduced-dimensional matrix and the second increased-dimensional matrix of the local LoRA to be trained are injected by the bypass into the Transformer layer of the local pre-trained large language model to construct the local LoRA network, and the lightweight context cache is used as input for forward propagation prediction. Extract the attention variance of the currently participating heavy word units, and dynamically calculate the corresponding LoRA feature scaling factor accordingly; The feature output of the local LoRA network is adaptively weighted using the LoRA feature scaling coefficient, and then added and fused with the base output of the pre-trained large language model; By combining the prediction results with real interaction data, a loss function containing role constraint penalty terms is calculated. Backpropagation is then performed, updating only the parameters of the first reduced-dimensional matrix and the second increased-dimensional matrix of the local LoRA, thereby generating the local role constraint gradient.
4. The method for cross-device data collaborative training of LoRa role models based on H2O according to claim 1, characterized in that, The process of performing cross-device secure synchronization of the local role constraint gradients of each terminal device, extracting the H2O cache retention rate of each terminal device as an adaptive weight factor on the central server, and performing weighted aggregation of the local role constraint gradients to generate a global aggregated gradient specifically includes: Each terminal device calculates the average cache retention rate of its local dynamic H2O mechanism during the current training cycle and generates the corresponding H2O cache retention rate. The local role constraint gradient is quantized, compressed, and subjected to differential privacy encryption to generate a ciphertext gradient. Each terminal device uploads the encrypted gradient along with the H2O cache retention rate to the central server via a secure link; After the central server decrypts the encrypted gradient, it normalizes the H2O cache retention rate of each terminal device into the adaptive weight factor and executes the federated adaptive weighted average algorithm to generate the global aggregate gradient.
5. The method for cross-device data collaborative training of LoRa role models based on H2O according to claim 1, characterized in that, The central server updates the global LoRA model parameters based on the global aggregated gradient, and then distributes the updated global LoRA model parameters to each terminal device for local synchronization. Specifically, this includes: The central server uses the optimizer to apply the global aggregated gradient to the global LoRA model parameters, completing one round of iterative update of the global role model; The updated global role model is inferred using the standard role evaluation validation set to calculate role feature offsets; If the character feature offset is lower than the preset security consistency threshold, then calculate the parameter difference between the current global LoRA model parameters and the parameters of the previous round; The parameter difference values are then sent to all terminal devices participating in this round of collaborative training. The terminal device receives the parameter difference and merges the corresponding elements with the parameters of the existing local LoRA network to complete local synchronization.
6. A cross-device data collaborative training system for LoRa role models based on H2O, characterized in that, The system employs the cross-device data collaborative training method for LoRa role models based on H2O as described in any one of claims 1-5, wherein the system comprises: The role-aware cache optimization module is used to perform local feature filtering on the role interaction text on the terminal device by using a dynamic H2O mechanism that combines role semantic weights, and to build a lightweight context cache that locks the role anchor point. The dynamic feature scaling gradient calculation module is used to perform forward propagation of the local LoRA network based on the lightweight context cache, and dynamically calculate the LoRA feature scaling coefficient according to the attention distribution of heavy words selected by the dynamic H2O mechanism, thereby generating the local role constraint gradient. The aggregation module based on cache retention rate is used to perform cross-device secure synchronization of the local role constraint gradients of each terminal device, and extract the H2O cache retention rate of each terminal device as an adaptive weight factor on the central server side, and perform weighted aggregation on the local role constraint gradients to generate a global aggregated gradient. The global parameter evolution and synchronization module is used to update the global LoRA model parameters on the central server based on the global aggregated gradient, and to distribute the updated global LoRA model parameters to each terminal device for local synchronization.
7. The cross-device data collaborative training system for LoRa role models based on H2O according to claim 6, characterized in that, The role-aware cache optimization module specifically includes: The text parsing and stripping unit is used to strip static character setting text and dynamic multi-turn dialogue text and convert them into word sequence; Anchor point locking unit is used to assign an absolute retention weight to the character setting text and lock it in the local key-value cache; The perception score generation unit is used to fuse the standard attention score with the character's semantic similarity to generate the character's perception attention score; The dynamic cache eviction unit is used to generate the lightweight context cache by executing an eviction mechanism based on the role perception attention score.
8. The cross-device data collaborative training system for LoRa role models based on H2O according to claim 6, characterized in that, The dynamic feature scaling gradient calculation module specifically includes: The network bypass injection unit is used to inject the local LoRA dimensionality reduction matrix A and the dimensionality increase matrix B to construct the local LoRA network and perform forward prediction. The scaling factor derivation unit is used to extract the attention variance of heavy words to generate the LoRA feature scaling factor; An adaptive weighted fusion unit is used to weight the feature output using the scaling coefficient and fuse it with the base output; A constraint backpropagation unit is used to calculate the loss function and update the parameters to generate the local role constraint gradient.
9. The cross-device data collaborative training system for LoRa role models based on H2O according to claim 6, characterized in that, The aggregation module based on cache retention rate specifically includes: The retention rate statistics unit is used to count and generate the local H2O cache retention rate; the encryption and desensitization unit is used to quantize and encrypt the local role constraint gradient to generate ciphertext gradient; the secure transmission unit is used to upload the ciphertext gradient and the H2O cache retention rate to the central server. The decryption and weighted aggregation unit is used to decrypt the ciphertext and normalize the H2O cache retention rate into weight factors, ultimately generating the global aggregated gradient.