A key-value cache compression method and device for power distribution network equipment anomaly detection

CN122594350APending Publication Date: 2026-08-18ELECTRIC POWER RES INST OF STATE GRID ZHEJIANG ELECTRIC POWER COMAPNY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611089815.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-22
Publication Date
2026-08-18

AI Technical Summary

Technical Problem

[0003]然而,该模型推理开销大,在高分辨率配电网设备图像输入模型时会产生海量冗余键值(KV)缓存,导致显存占用高、推理延迟大,难以满足实时巡检需求

Benefits of technology

一方面,本发明通过多模态大模型的视觉编码器提取配电网设备图像的补丁特征实现异常区域边界的定位,并根据配电网设备图像的结构语义边界与异常区域的分布信息构建具备语义边界隔离的异常重要性场,既聚焦缺陷周边关键诊断纹理,又抑制跨语义边界的无效缓存扩散,从而提升了KV缓存压缩的精确度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122594350A_ABST
    Figure CN122594350A_ABST
Patent Text Reader

Abstract

This invention belongs to the field of caching and discloses a key-value cache compression method and apparatus for anomaly detection in power distribution network equipment. The method includes: extracting patch features from images of power distribution network equipment using a multimodal large-scale visual encoder, and generating an image anomaly heatmap reflecting defect distribution by comparing features with those of normal samples of the same category; constructing an anomaly importance field with semantic boundary isolation based on the structural semantic boundaries and distribution information of anomaly regions in the images of power distribution network equipment; dividing the image patch network into multiple non-overlapping feature blocks, adaptively allocating the total number of key-value cache tokens for each image of power distribution network equipment, and differentially allocating token retention quotas according to the importance weights of each feature block; filtering and retaining visual tokens according to importance priority, and simplifying text tokens by combining anchor point forced retention with general content downsampling; and fusing the filtered visual and text tokens to generate a compressed key-value cache.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of caching, and in particular relates to a key-value caching compression method and apparatus for anomaly detection of power distribution network equipment. Background Technology

[0002] Anomaly detection in power distribution network equipment is a core aspect of power system operation and maintenance. Multimodal Large Language Model (MLLM), with its powerful visual understanding and cross-domain reasoning capabilities, has been gradually introduced into this field to identify defects and appearance anomalies in equipment components.

[0003] However, this model has high inference overhead. When high-resolution images of power distribution network equipment are input into the model, a massive amount of redundant key-value (KV) cache is generated, resulting in high memory usage and large inference latency, making it difficult to meet the needs of real-time inspection. Furthermore, when processing equipment images, MLLM often focuses excessively on normal metal and insulator surfaces, while paying insufficient attention to abnormal defect areas such as tiny cracks and corrosion, leading to missed detections.

[0004] In related technologies, KV cache compression methods (such as SnapKV and PyramidKV) are mostly general designs that lack specific protection mechanisms for "abnormal regions". During the compression process, key defect features are easily pruned, resulting in a significant decrease in detection accuracy. Summary of the Invention

[0005] In view of this, the present invention discloses a key-value cache compression method and apparatus for anomaly detection of power distribution network equipment, which can solve the shortcomings of related technologies.

[0006] To achieve the above objectives, the present invention discloses the following technical solution: According to a first aspect of the present invention, a key-value caching compression method for anomaly detection in power distribution network equipment is proposed, comprising: A visual encoder based on a multimodal large model extracts patch features from images of power distribution network equipment and generates an image anomaly heatmap reflecting the distribution of defects by comparing the features with those of normal samples of the same category, so as to locate the boundaries of abnormal areas. Based on the structural semantic boundaries and distribution information of abnormal regions in the images of power distribution network equipment, an anomaly importance field with semantic boundary isolation is constructed. The anomaly importance of a region in the anomaly importance field is used to characterize the severity of the anomaly in that region. The image patch network generated by the visual encoder is divided into multiple non-overlapping feature blocks. Based on the severity of the anomaly of a single power distribution equipment image, the total number of key-value cache tokens to be retained for each power distribution equipment image is adaptively allocated, and the token retention quota is allocated differently according to the importance weight of each feature block. Visual tokens are filtered and retained according to their importance priority, while text tokens are simplified by combining anchor point forced retention with general content downsampling. The filtered visual and text tokens are then merged to generate a compressed key-value cache for model inference.

[0007] According to a second aspect of the present invention, a key-value caching and compression device for anomaly detection in power distribution network equipment is provided, comprising: Extraction Unit: Based on a multimodal large model, the visual encoder extracts patch features from the images of power distribution network equipment and generates an image anomaly heatmap reflecting the distribution of defects by comparing the features with those of normal samples of the same category, so as to locate the boundaries of the abnormal area. Construction Unit: Based on the structural semantic boundaries and distribution information of abnormal regions in the images of power distribution network equipment, an anomaly importance field with semantic boundary isolation is constructed. The anomaly importance of a region in the anomaly importance field is used to characterize the severity of the anomaly in that region. Allocation Unit: Divides the image patch network generated by the visual encoder into multiple non-overlapping feature blocks. Based on the severity of anomalies in a single power distribution network equipment image, it adaptively allocates the total number of key-value cache tokens for each power distribution network equipment image and allocates token retention quotas differently according to the importance weight of each feature block. Fusion Unit: Visual tokens are filtered and retained according to importance priority, and text tokens are simplified by combining anchor point forced retention with general content downsampling. The fused visual and text tokens generate a compressed key-value cache for model inference.

[0008] According to a third aspect of the present invention, an electronic device is provided, comprising: processor; Memory used to store processor-executable instructions; The processor implements the steps of the method as described in the first aspect by running the executable instructions.

[0009] According to a fourth aspect of the invention, a computer-readable storage medium is provided having computer instructions stored thereon that, when executed by a processor, implement the steps of the method as described in the first aspect.

[0010] As can be seen from the above technical solutions, the key-value caching compression method and device for anomaly detection in power distribution network equipment disclosed in this invention have the following beneficial effects: On the one hand, the present invention extracts patch features from the images of power distribution equipment using a multimodal large model visual encoder to locate the boundaries of abnormal regions. On the other hand, it constructs an abnormal importance field with semantic boundary isolation based on the structural semantic boundary of the images of power distribution equipment and the distribution information of abnormal regions. This not only focuses on key diagnostic textures around defects but also suppresses the spread of invalid cache across semantic boundaries, thereby improving the accuracy of KV cache compression.

[0011] On the other hand, the present invention adopts an instance-level dynamic budget allocation mechanism, which can adaptively adjust the KV cache retention ratio according to the severity of the anomaly in each distribution network equipment anomaly image. Normal background areas are compressed at a high ratio, and abnormal areas are retained with emphasis, maintaining near-lossless anomaly inference accuracy with extremely low cache usage.

[0012] Furthermore, this invention eliminates the need for model fine-tuning and additional training overhead. Its modular design is compatible with multiple mainstream multimodal large models, and it reduces inference latency and memory overhead in all-scenario power distribution network equipment anomaly detection tasks. It is suitable for real-time inference scenarios involving multiple types of high-resolution visual anomalies. Attached Figure Description

[0013] Figure 1 This is a flowchart of a key-value caching compression method for anomaly detection in power distribution network equipment, provided in an exemplary embodiment; Figure 2 This is a schematic diagram of an exemplary embodiment of a KV cache compression architecture for anomaly detection in power distribution network equipment; Figure 3 This is a schematic structural diagram of a device provided in an exemplary embodiment; Figure 4 This is a block diagram of a key-value caching compression device for anomaly detection in power distribution network equipment, provided in an exemplary embodiment. Detailed Implementation

[0014] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of one or more embodiments of the present invention as detailed in the appended claims.

[0015] It should be noted that the steps of the corresponding methods in other embodiments are not necessarily performed in the order shown and described in this invention. In some other embodiments, the methods may include more or fewer steps than those described in this invention. Furthermore, a single step described in this invention may be broken down into multiple steps in other embodiments; and multiple steps described in this invention may be combined into a single step in other embodiments.

[0016] Anomaly detection in power distribution network equipment is a core technology in the power sector, enabling the identification of abnormal defects, assessment of abnormal operating conditions, and risk warnings. It plays an irreplaceable role in power operation and maintenance. Traditional equipment anomaly detection methods mostly rely on threshold judgment and normal sample feature distribution modeling. They can only complete defect screening using conventional image processing methods. This not only makes it difficult to obtain high-quality standard normal samples, but also makes it impossible to accurately locate unknown defects or output interpretable defect cause reasoning logic. Consequently, their generalization ability and practical applicability are limited.

[0017] With the rapid development of Multimodal Large Language Models (MLLM), which possess powerful global visual understanding and zero-shot cross-domain reasoning capabilities, they have been gradually introduced into the task of anomaly detection in power distribution networks. Existing research mainly focuses on improving the anomaly reasoning accuracy of MLLM, but generally ignores the problem of high inference overhead of the model; especially when dealing with high-resolution images of anomalies in power distribution networks, MLLM generates massive redundant key-value (KV) caches, resulting in huge memory consumption and inference latency, making it difficult to implement in real-time deployment in large-scale power distribution network detection scenarios.

[0018] In related technologies, KV caching compression methods such as SnapKV, AdaKV, and PyramidKV are all designed for general text and general vision tasks, relying solely on attention scores to filter important KV positions without being customized for distribution network equipment anomaly detection tasks. Research has found that MLLM has inherent attention defects in the inference process of distribution network equipment anomaly detection: the model's attention is largely concentrated on normal areas of the distribution network equipment image, while the effective attention ratio obtained in abnormal and defective areas is extremely low, which easily leads to incomplete anomaly perception; while general KV compression methods cannot perform targeted importance assessment of KV pairs in abnormal areas, and the compression process easily loses key defect features, resulting in a significant decrease in detection accuracy. In addition, existing compression methods mostly use fixed cache budgets and globally uniform compression ratios, and cannot perform instance-level dynamic compression based on the anomaly distribution and defect severity of different distribution network equipment samples, making it difficult to achieve a balance between compression efficiency and anomaly recognition performance.

[0019] To address the shortcomings of related technologies, this invention proposes a key-value caching compression method and apparatus for anomaly detection in power distribution network equipment.

[0020] Figure 1 This is a flowchart illustrating a key-value cache compression method for anomaly detection in power distribution network equipment, as provided in an exemplary embodiment. Figure 1 As shown, the method may include the following steps: Step 101: Extract patch features from the images of power distribution network equipment using a visual encoder based on a multimodal large model, and generate an image anomaly heatmap reflecting the distribution of defects by comparing the features with those of normal samples of the same category, so as to locate the boundaries of the abnormal area.

[0021] Specifically, such as Figure 2 As shown, the step of generating an image anomaly heatmap reflecting the defect distribution by comparing features with normal samples of the same category includes: calculating the Euclidean distance between features of different power distribution equipment images of the same category patch by patch, and calculating the minimum distance between each patch and other image patches of the same category; taking the mean of the low quantile interval of the distance distribution as the anomaly score of the patch, and aggregating the anomaly scores of all patches to obtain the anomaly heatmap.

[0022] First, high-resolution image datasets of abnormal scenarios of power distribution network equipment are collected, and then grouped by product category to form image sample sets of the same category.

[0023] Next, the built-in visual encoder of the multimodal large model is reused, a fixed intermediate layer is selected as the feature output layer, the patch feature tensor of each group of abnormal images of power distribution equipment is extracted, and L2 normalization processing is performed along the channel dimension.

[0024] Then, for all images within the same category, the minimum L2 nearest neighbor distance from each patch to the image is calculated patch by patch to construct the complete distance matrix.

[0025] For any two different images within the same category, calculate the L2 shortest distance of features patch by patch. The calculation formula is as follows: ; in, Represents the i-th image. The patch is the minimum feature distance relative to all patches in the j-th image; i represents the sequence number of the current abnormal image of the distribution network equipment to be detected; j represents the sequence number of other comparison images in the same category (j≠i). Indicates the index of the current image patch; Let represent the patch feature tensor after L2 normalization of the i-th image.

[0026] Stack all patch distance results to form a dimension of The distance matrix provides a data foundation for subsequent anomaly scoring.

[0027] Finally, a fixed low quantile interval is set, and the distance matrix is ​​aggregated by interval mean to calculate the anomaly score for each patch, generating an image anomaly heatmap. Then, through threshold segmentation and connected component fitting, a standardized set of anomaly bounding boxes is output, completing coarse-grained, training-free defect localization. The anomaly score calculation formula is as follows: ; in, Represents the i-th image. Anomaly rating for each patch; This represents the distance feature matrix composed of all patches in the entire image; Indicates the starting index of the lower quantile interval; The index represents the terminating index of the lower quantile interval; N represents the total number of images in the same category.

[0028] Step 102: Based on the structural semantic boundary and distribution information of abnormal regions in the distribution network equipment image, construct an anomaly importance field with semantic boundary isolation. The anomaly importance of a region in the anomaly importance field is used to characterize the severity of the anomaly in that region.

[0029] Specifically, based on the structural semantic boundaries and distribution information of abnormal regions in the images of power distribution network equipment, an anomaly importance field with semantic boundary isolation is constructed, including: calculating the gradient L2 norm based on the spatial gradient information of the patch features, and constructing a semantic structural boundary map, which is used to block the diffusion of importance weights across semantic regions; using the abnormal bounding box as a reference, calculating the box coverage ratio and Gaussian distance decay coefficient at each pixel position, and fusing the box coverage ratio, the Gaussian decay coefficient, and the structural boundary factor to construct a reaction-diffusion source term; introducing an anisotropic reaction-diffusion equation, using a damped Jacobian iteration method for numerical solution, and after iterative convergence, fusing structural features for normalization to generate the anomaly importance field; the iterative formula is: ; in, Represents the importance field in the t-th iteration; This represents the iterative relaxation coefficient, which controls the convergence speed. This represents the four-neighbor summation operator; This represents the harmonic mean of the neighborhood edges.

[0030] Further, the step of calculating the gradient L2 norm based on the spatial gradient information of the patch features and constructing a semantic structure boundary graph includes: Calculate the spatial finite difference gradient norm of the patch features and construct the semantic structure boundary graph: ; in, Represents the coordinates of the i-th image. Structural boundary response values ​​at the location; Represents the horizontal and vertical coordinates of the patch grid; Representing coordinates Normalized visual features; The semantic structure boundary graph has higher values ​​at the edges of power distribution equipment and components, and lower values ​​in flat background areas.

[0031] The diffusion source term is constructed, specifically as follows: Calculate the percentage of the area covered by the exception box in the patch calculation. And the Gaussian decay coefficient from the patch to the nearest outlier box: ; in, This represents the set of all abnormal bounding boxes in the i-th image; Represents a single anomaly bounding box; Indicates the current coordinates Spatial distance to the nearest exception box; This represents the hyperparameter of the Gaussian kernel width, which controls the rate of importance decay.

[0032] The diffusion source term is constructed by incorporating multiple factors, as shown in the following formula: ; in, This represents the global gain coefficient, which controls the overall magnitude of the source term; This indicates the percentage of the patch area covered by the exception box; , Indicates the weighting coefficient; This represents the Gaussian distance attenuation coefficient; This indicates the lower limit of the structure factor, preventing the structure weight from being too low in flat regions.

[0033] Step 103: Divide the image patch network generated by the visual encoder into multiple non-overlapping feature blocks. Based on the severity of the anomaly of a single power distribution network equipment image, adaptively allocate the total number of key-value cache tokens for each power distribution network equipment image, and allocate token retention quotas differently according to the importance weight of each feature block.

[0034] First, the entire image patch grid is divided into fixed-size, non-overlapping feature blocks. The average importance value within each block is calculated and used as the importance score for that feature block. The calculation formula is as follows: ; in, This represents the r-th non-overlapping feature block region; This indicates the importance value of each coordinate point within the block.

[0035] Next, the upper and lower limits of the global retention ratio are set, and the KV cache retention ratio of each image is adaptively calculated based on the global importance average of a single image.

[0036] Specifically, based on the severity of anomalies in a single distribution network equipment image, the total amount of key-value cache retention for each distribution network equipment image is adaptively allocated. This includes: setting upper and lower thresholds for the global key-value cache retention ratio, and using the average anomaly importance of all feature blocks in a single distribution network equipment image as an adjustment coefficient to linearly map and obtain the specific retention ratio for each distribution network equipment image; and calculating the total number of key-value cache retention tokens for each distribution network equipment image based on the total number of image patches and the corresponding specific retention ratio.

[0037] Using the mean global importance of the image as the adaptive benchmark, the calculation formula is as follows: ; in, The adaptive KV cache retention ratio for the i-th image; : The lower limit of the global minimum retention ratio; : The maximum global retention ratio limit; : Global mean of importance field for the entire image.

[0038] 3.2.2) Determine the total number of tokens to be retained for a single image based on the retention ratio: .

[0039] Then, based on the adaptive retention ratio, the total number of tokens that need to be retained for a single image is calculated; Finally, token quotas are allocated according to the importance ratio of each feature block, a minimum retention base is set for each block, and high, medium and low retention blocks are divided. Differentiated token retention strategies are implemented for defect core areas, edge areas and normal background areas.

[0040] Step 104: Visual tokens are filtered and retained according to their importance priority, and text tokens are simplified by combining anchor point forced retention with general content downsampling. The filtered visual and text tokens are then merged to generate a compressed key-value cache for model inference.

[0041] Specifically, the visual tokens are selected and retained according to importance priority, including: sorting them from high to low according to the importance weight of the feature blocks, prioritizing the retention of patch tokens corresponding to abnormal core areas, and cropping redundant tokens in distant normal background areas; the text tokens are simplified by combining anchor point forced retention with general content downsampling, including: retaining system identifiers, special image markers, key text in user questions and at the end of the generated results, and simplifying the remaining general template text by uniform downsampling.

[0042] First, for visual tokens, they are sorted according to the importance score of each feature block, and the tokens of patches around high-importance defects are selected and retained, while redundant tokens of distant normal background are compressed.

[0043] Next, for text tokens, an anchor retention strategy is adopted to unconditionally retain system identifiers, special image markers, user questions, and key text at the end, constructing a fixed set of retained text: ; in, : An unconditionally reserved set of anchor tokens (system header, image special markers); A fixed set of tail text tokens; : The token set after downsampling of the general template text.

[0044] Then, the remaining general template text is simplified by uniform downsampling, reducing the text key-value cache usage without losing semantic information.

[0045] Finally, the filtered visual tokens and text tokens are merged to generate a globally unified token selection scheme. During the model pre-filling stage, only key-value pairs with corresponding indices are retained to generate a compressed KV cache. The calculation formula is as follows: ; in, , This represents the original full key-value cache matrix of the model; This represents the global token selection index set that integrates visual and textual elements; , This indicates the KV buffer retained after compression, which is only used for subsequent inference and decoding. In this embodiment, on the one hand, the present invention extracts patch features from distribution network equipment images using a multimodal large-scale visual encoder to locate the boundaries of abnormal regions. Based on the structural semantic boundaries of the distribution network equipment images and the distribution information of abnormal regions, it constructs an anomaly importance field with semantic boundary isolation. This focuses on key diagnostic textures around defects while suppressing the spread of invalid cache across semantic boundaries, thereby improving the accuracy of KV cache compression. On the other hand, the present invention employs an instance-level dynamic budget allocation mechanism, which adaptively adjusts the KV cache retention ratio according to the severity of anomalies in each distribution network equipment image. Normal background areas are compressed at a high ratio, while abnormal areas are retained with emphasis, maintaining near-lossless anomaly inference accuracy with extremely low cache usage. Furthermore, the present invention requires no model fine-tuning or additional training overhead. Its modular design is compatible with multiple mainstream multimodal large-scale models, and it reduces inference latency and memory overhead in full-scene distribution network equipment anomaly detection tasks, making it suitable for various high-resolution visual anomaly real-time inference scenarios.

[0046] In one embodiment, the method further includes: during the model pre-filling stage, only the key-value pairs corresponding to the filtering index are retained to generate a static pre-compressed cache, and the same token selection scheme is shared in all attention layers of the model; during the decoding stage, the pre-compressed cache is called to complete the inference to avoid recalculating key-value features.

[0047] The proposed method is validated in three typical scenarios within the power industry. AnomalyCoT, an authoritative benchmark for anomaly detection in distribution network equipment, is used as the evaluation standard. It includes ten mainstream subset datasets such as MVTecAD, VisA, and MPDD, and features accurate defect bounding box annotations and long-chain inference annotations, comprehensively assessing the model's anomaly recognition accuracy and inference efficiency.

[0048] 1. Hardware and Inference Environment: All application experiments were deployed on a server platform equipped with eight NVIDIA RTX 4090 GPUs; the inference batch was fixed at 1, and the graph-by-graph independent inference mode was adopted; the decoding strategy was greedy decoding, the inference temperature was set to 0, and the maximum generation length was fixed at 512 tokens; each experiment was repeated three times, and the average end-to-end inference time was taken as the final latency indicator.

[0049] Text correction module: Bidirectional text generator based on CLIP model; 2. Hyperparameter Configuration: In application testing, the core parameters were fixed as follows: the visual encoder selected the 7th layer feature output, the LAMS threshold was set to 0.8, the low quantile interval was fixed at (0, 0.3); the feature block size b=16, the KV retention ratio range was set to 0.05~0.20, the minimum retention cardinality per block was 1; the reaction-diffusion iteration number was set to 8 rounds, the number of tokens retained at the end of the text was fixed at τ=40, and the system text sampling ratio was set to 0. The evaluation indicators and calculation methods employ a comprehensive assessment using both inference accuracy and inference time as dual indicators: Inference accuracy: Based on the official AnomalyCoT evaluation rules, the model's comprehensive ability to identify defect categories, locate abnormal areas, and match inference logic is evaluated. The higher the mean, the better the anomaly perception effect.

[0050] Inference time: The end-to-end inference time for a single image is statistically analyzed, including the entire process of feature extraction, anomaly localization, caching and compression, and decoding and generation. The lower the time, the better the inference acceleration effect.

[0051] F1 score: .

[0052] In the AnomalyCoT ten-subset evaluation, this invention achieved an average inference accuracy close to that of the full KV uncompressed model on multiple models including Qwen2.5-VL, InternVL3, and Gemma4-E, with negligible performance degradation. Under the same cache budget, it outperformed existing compression methods such as SnapKV, AdaKV, and PyramidKV, with an average accuracy increase of approximately 4% to 5%. Especially in scenarios with small defects, weak textures, and complex interference, this invention, through its anomaly perception enhancement mechanism, avoids the problem of losing key defect features in general compression methods, thus reducing the false negative and false positive rates.

[0053] Figure 3 This is a schematic structural diagram of a device provided in an exemplary embodiment. Please refer to... Figure 3 At the hardware level, the device includes a processor 302, an internal bus 304, a network interface 306, memory 308, and non-volatile memory 310, and may also include other hardware required for its functions. One or more embodiments of the present invention can be implemented in software, for example, the processor 302 reads the corresponding computer program from the non-volatile memory 310 into memory 308 and then runs it. Of course, in addition to software implementation, one or more embodiments of the present invention do not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0054] Please refer to Figure 4 A key-value caching and compression device for anomaly detection in power distribution network equipment can be applied to, for example... Figure 4 The device shown, in order to implement the technical solution of the present invention, includes: Extraction unit 401 is used to extract patch features of power distribution equipment images based on a multimodal large model visual encoder, and generate an image anomaly heat map reflecting the defect distribution by comparing the features with those of normal samples of the same category, so as to locate the boundary of the abnormal area. The construction unit 402 is used to construct an anomaly importance field with semantic boundary isolation based on the structural semantic boundary and distribution information of anomaly regions in the distribution network equipment image. The anomaly importance of a region in the anomaly importance field is used to characterize the severity of the anomaly in that region. The allocation unit 403 is used to divide the image patch network generated by the visual encoder into multiple non-overlapping feature blocks, adaptively allocate the total number of key-value cache tokens for each distribution network equipment image based on the severity of the anomaly of a single distribution network equipment image, and allocate the token retention quota differently according to the importance weight of each feature block. The fusion unit 404 is used to filter and retain visual tokens according to their importance priority, and to simplify text tokens by combining anchor point forced retention with general content downsampling. The fused and filtered visual and text tokens generate a compressed key-value cache for model inference.

[0055] Optionally, the extraction unit 401 is specifically used for: For images of different power distribution equipment of the same category, calculate the Euclidean distance between features patch by patch, and calculate the minimum distance between each patch and other image patches of the same category; The mean of the low quantile interval of the distance distribution is taken as the anomaly score of the patch, and the anomaly scores of all patches are aggregated to obtain the anomaly heatmap.

[0056] Optionally, the building unit 402 is specifically used for: Based on the spatial gradient information of the patch features, the gradient L2 norm is calculated, and a semantic structure boundary graph is constructed. The semantic structure boundary graph is used to prevent the diffusion of importance weights across semantic regions. Based on the abnormal bounding box, calculate the box coverage ratio and Gaussian distance decay coefficient at each pixel position, and fuse the box coverage ratio, the Gaussian decay coefficient and the structural boundary factor to construct the reaction diffusion source term; An anisotropic reaction-diffusion equation is introduced, and a damped Jacobian iteration method is used for numerical solution. After the iteration converges, the structural features are fused and normalized to generate the aforementioned anomaly importance field; the iterative formula is: ; in, Represents the importance field in the t-th iteration; This represents the iterative relaxation coefficient, which controls the convergence speed. This represents the four-neighbor summation operator; This represents the harmonic mean of the neighborhood edges.

[0057] Furthermore, the building unit 402 is specifically used for: Calculate the spatial finite difference gradient norm of the patch features and construct the semantic structure boundary graph: ; in, Represents the coordinates of the i-th image. Structural boundary response values ​​at the location; Represents the horizontal and vertical coordinates of the patch grid; Representing coordinates Normalized visual features; The semantic structure boundary graph has higher values ​​at the edges of power distribution equipment and components, and lower values ​​in flat background areas.

[0058] Optionally, the adaptive allocation of the total key-value cache retention amount for each distribution network equipment image based on the severity of anomalies in a single distribution network equipment image includes: The upper and lower limits of the global key-value cache retention ratio are preset, and the average value of the abnormal importance of all feature blocks in a single distribution network equipment image is used as the adjustment coefficient to obtain the exclusive retention ratio of each distribution network equipment image through linear mapping. The total number of key-value cached tokens for each power distribution equipment image is calculated based on the total number of image patches and the corresponding dedicated retention ratio.

[0059] Optionally, the building unit 402 is specifically used to: sort the feature blocks from high to low importance weights, prioritize retaining the patch tokens corresponding to the abnormal core area, and prune redundant tokens in the distant normal background area; The system identifier, special image markers, user questions, and key text at the end of the generated results are retained, and the remaining general template text is simplified using a uniform downsampling method.

[0060] Optional, also includes: The generation unit 405 is used to retain only the key-value pairs corresponding to the filtering index during the model pre-filling stage, generate a static pre-compressed cache, and share the same token selection scheme in all attention layers of the model. Calling unit 406 is used to call the pre-compressed cache to complete inference during the decoding stage, so as to avoid repeatedly calculating key-value features.

[0061] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which can take the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email sending and receiving device, game console, tablet computer, wearable device, or any combination of these devices.

[0062] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0063] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0064] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0065] For any other form of computer-readable medium (or computer-readable storage medium) as described above, computer instructions may be stored thereon, which, when executed by a processor, implement one or more of the above embodiments, thereby realizing the technical solution of the present invention.

[0066] The present invention also proposes a computer program that, when executed by a processor, implements one or more of the embodiments described above, thereby realizing the technical solution of the present invention. This computer program may be specifically recorded on the above-described or other computer-readable media, and the present invention does not impose any limitations on this.

[0067] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0068] The foregoing has described specific embodiments of the invention. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims may be performed in a different order than that shown in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0069] The terminology used in one or more embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to limit the invention. The singular forms “a,” “the,” and “the” used in one or more embodiments of the invention and in the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0070] It should be understood that although the terms first, second, third, etc., may be used to describe various information in one or more embodiments of the present invention, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first information may also be referred to as second information without departing from the scope of one or more embodiments of the present invention, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."

[0071] The above description is merely a preferred embodiment of one or more embodiments of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of one or more embodiments of the present invention should be included within the protection scope of one or more embodiments of the present invention.

Claims

1. A key-value caching compression method for anomaly detection in power distribution network equipment, characterized in that, include: A visual encoder based on a multimodal large model extracts patch features from images of power distribution network equipment and generates an image anomaly heatmap reflecting the distribution of defects by comparing the features with those of normal samples of the same category, in order to locate the boundaries of abnormal areas. Based on the structural semantic boundaries and distribution information of abnormal regions in the images of power distribution network equipment, an anomaly importance field with semantic boundary isolation is constructed. The anomaly importance of a region in the anomaly importance field is used to characterize the severity of the anomaly in that region. The image patch network generated by the visual encoder is divided into multiple non-overlapping feature blocks. Based on the severity of the anomaly of a single power distribution equipment image, the total number of key-value cache tokens to be retained for each power distribution equipment image is adaptively allocated, and the token retention quota is allocated differently according to the importance weight of each feature block. Visual tokens are filtered and retained according to their importance priority, while text tokens are simplified by combining anchor point forced retention with general content downsampling. The filtered visual and text tokens are then merged to generate a compressed key-value cache for model inference.

2. The method according to claim 1, characterized in that, The step of generating an image anomaly heatmap reflecting the distribution of defects by comparing features with normal samples of the same category includes: For images of different power distribution equipment of the same category, calculate the Euclidean distance between features patch by patch, and calculate the minimum distance between each patch and other image patches of the same category; The mean of the low quantile interval of the distance distribution is taken as the anomaly score of the patch, and the anomaly scores of all patches are aggregated to obtain the anomaly heatmap.

3. The method according to claim 1, characterized in that, The step of constructing an anomaly importance field with semantic boundary isolation based on the structural semantic boundaries and distribution information of anomaly regions in the distribution network equipment image includes: Based on the spatial gradient information of the patch features, the gradient L2 norm is calculated, and a semantic structure boundary graph is constructed. The semantic structure boundary graph is used to prevent the diffusion of importance weights across semantic regions. Based on the abnormal bounding box, calculate the box coverage ratio and Gaussian distance decay coefficient at each pixel position, and fuse the box coverage ratio, the Gaussian decay coefficient and the structural boundary factor to construct the reaction diffusion source term; An anisotropic reaction-diffusion equation is introduced, and a damped Jacobian iteration method is used for numerical solution. After the iteration converges, the structural features are fused and normalized to generate the aforementioned anomaly importance field; the iterative formula is: ; in, Represents the importance field in the t-th iteration; This represents the iterative relaxation coefficient, which controls the convergence speed. This represents the four-neighbor summation operator; This represents the harmonic mean of the neighborhood edges.

4. The method according to claim 3, characterized in that, The calculation of the gradient L2 norm and the construction of a semantic structure boundary graph based on the spatial gradient information of the patch features include: Calculate the spatial finite difference gradient norm of the patch features and construct the semantic structure boundary graph: ; in, Represents the coordinates of the i-th image. Structural boundary response values ​​at the location; Represents the horizontal and vertical coordinates of the patch grid; Representing coordinates Normalized visual features; The semantic structure boundary graph has higher values ​​at the edges of power distribution equipment and components, and lower values ​​in flat background areas.

5. The method according to claim 1, characterized in that, The method of adaptively allocating the total amount of key-value cache retention for each distribution network equipment image based on the severity of anomalies in a single distribution network equipment image includes: The upper and lower limits of the global key-value cache retention ratio are preset, and the average value of the abnormal importance of all feature blocks in a single distribution network equipment image is used as the adjustment coefficient to obtain the exclusive retention ratio of each distribution network equipment image through linear mapping. The total number of key-value cached tokens for each power distribution equipment image is calculated based on the total number of image patches and the corresponding dedicated retention ratio.

6. The method according to claim 1, characterized in that, The process of filtering and retaining visual tokens according to their importance priority includes: sorting them from high to low according to the importance weight of the feature blocks, prioritizing the retention of patch tokens corresponding to abnormal core areas, and pruning redundant tokens in distant normal background areas. The text token is simplified by combining anchor point forced retention with general content downsampling. This includes: retaining the system identifier, special image markers, key text at the end of user questions and generated results, and simplifying the remaining general template text by uniform downsampling.

7. The method according to claim 1, characterized in that, Also includes: During the model pre-filling stage, only the key-value pairs corresponding to the filtering index are retained to generate a static pre-compressed cache, and the same token selection scheme is shared in all attention layers of the model. During the decoding phase, the pre-compressed cache is invoked to complete the inference process, in order to avoid repeatedly calculating key-value features.

8. A key-value caching and compression device for anomaly detection in power distribution network equipment, characterized in that, include: Extraction Unit: Based on a multimodal large model, the visual encoder extracts patch features from the images of power distribution network equipment and generates an image anomaly heatmap reflecting the distribution of defects by comparing the features with those of normal samples of the same category, so as to locate the boundaries of the abnormal area. Construction Unit: Based on the structural semantic boundaries and distribution information of abnormal regions in the images of power distribution network equipment, an anomaly importance field with semantic boundary isolation is constructed. The anomaly importance of a region in the anomaly importance field is used to characterize the severity of the anomaly in that region. Allocation Unit: Divides the image patch network generated by the visual encoder into multiple non-overlapping feature blocks. Based on the severity of anomalies in a single power distribution network equipment image, it adaptively allocates the total number of key-value cache tokens for each power distribution network equipment image and allocates token retention quotas differently according to the importance weight of each feature block. Fusion Unit: Visual tokens are filtered and retained according to importance priority, and text tokens are simplified by combining anchor point forced retention with general content downsampling. The fused visual and text tokens generate a compressed key-value cache for model inference.

9. An electronic device, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor implements the steps of the method as described in any one of claims 1-7 by running the executable instructions.

10. A computer-readable storage medium storing computer instructions thereon, characterized in that, When executed by the processor, this instruction implements the steps of the method as described in any one of claims 1-7.