Large language model security test data processing method and system

By dividing the memory space of a large-scale language model security testing platform into regions and constructing regional memory management units, the fragmentation problem of traditional memory management mechanisms when handling diverse and heterogeneous memory requests is solved, achieving efficient and reliable memory management and data processing.

CN121996567APending Publication Date: 2026-05-08BEIJING LINGYUN SHUKE INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING LINGYUN SHUKE INFORMATION TECH CO LTD
Filing Date
2026-01-12
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

Traditional memory management mechanisms struggle to cope with the diverse and heterogeneous memory request patterns in large-scale language model security testing, leading to memory fragmentation and low data processing efficiency, which affects evaluation efficiency and reliability.

Method used

By dividing the main memory space into regions and constructing regional memory management units, test data is allocated to the corresponding functional regions according to the memory allocation strategy, thereby achieving efficient memory management and allocation.

Benefits of technology

It improves the reliability of memory management and the efficiency of data processing, reduces memory fragmentation, and ensures a smooth testing process and in-depth security assessment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121996567A_ABST
    Figure CN121996567A_ABST
Patent Text Reader

Abstract

The invention discloses a big language model security test data processing method and system, and relates to the technical field of memory management, the method comprises the following steps: obtaining test data in a big language model security test platform, the test data comprising multi-modal data, structured attack load data, long-term session state data and short-term temporary data; according to the test data, performing region division on a main memory space to obtain a plurality of initial functional regions; constructing a corresponding regional memory management unit in each initial functional region, the regional memory management unit being used for performing memory allocation according to a memory allocation strategy; and after memory allocation, allocating the test data to the corresponding initial function region, and processing the test data. According to the method, the memory can be allocated in combination with the functional region and the memory allocation strategy, so that the test data has enough memory space, the test data processing is realized, and the memory management reliability and the data processing efficiency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of memory management technology, and in particular to a method and system for processing security test data of large language models. Background Technology

[0002] In the security assessment and deployment of large language models (LLMs), security testing platforms need to handle massive amounts of complex test data to probe for model vulnerabilities. Traditional methods allocate memory simply by identifying free memory space. However, test data has evolved from single texts to complex forms containing multimodal information, structured instruction sequences, and adversarial samples, placing high demands on memory continuity. Simultaneously, to simulate real attack scenarios, multiple test sessions need to run in parallel and maintain dynamically growing context information, which needs to reside in memory for extended periods. This highly heterogeneous memory request pattern (large size differences, varying lifecycles, and high continuity requirements) makes traditional memory management mechanisms inadequate, easily leading to severe external fragmentation. Even with sufficient total system memory, a lack of sufficiently large contiguous memory blocks can cause critical data allocation failures, interrupting the testing process, severely impacting evaluation efficiency, resulting in low memory management reliability and low data processing efficiency.

[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the Invention

[0004] The main objective of this invention is to propose a method and system for processing large language model security test data. This method can combine functional areas and memory allocation strategies to allocate memory, ensuring that the test data has sufficient memory space, thereby enabling test data processing and improving memory management reliability and data processing efficiency.

[0005] On one hand, embodiments of the present invention provide a method for processing large language model security test data, including the following steps: Acquire test data from the large language model security testing platform, including multimodal data, structured attack payload data, long-term session state data, and short-term temporary data; Based on the test data, the main memory space is divided into regions to obtain multiple initial functional regions, including a multimodal region, a structured attack payload region, a long-term session state region, or a short-term temporary region. A corresponding regional memory management unit is constructed in each initial functional area. The regional memory management unit is used to allocate memory according to the memory allocation strategy. After memory allocation, the test data is assigned to the corresponding initial functional area for test data processing.

[0006] On the other hand, embodiments of the present invention provide a large language model security test data processing system, including: The data acquisition module is used to acquire test data from the large language model security testing platform. The test data includes multimodal data, structured attack payload data, long-term session state data, and short-term temporary data. The region partitioning module is used to partition the main memory space into regions based on the test data to obtain multiple initial functional regions. The initial functional regions include multimodal regions, structured attack payload regions, long-term session state regions, or short-term temporary regions. A memory allocation module is used to construct a corresponding regional memory management unit in each initial functional area. The regional memory management unit is used to allocate memory according to a memory allocation strategy. The data allocation module is used to allocate the test data to the corresponding initial functional area after memory allocation for test data processing.

[0007] The embodiments of this application include at least the following beneficial effects: First, the embodiments of this application acquire test data from a large language model security testing platform. Then, based on the test data, the main memory space is divided into regions to obtain multiple initial functional regions. Next, a corresponding regional memory management unit is constructed in each initial functional region. Memory allocation is performed through the regional memory management unit according to the memory allocation strategy. Finally, the test data is allocated to the corresponding initial functional region for test data processing. This allows for memory allocation by combining functional regions and memory allocation strategies, ensuring that the test data has sufficient memory space, thereby enabling test data processing and improving memory management reliability and data processing efficiency.

[0008] Other features and advantages of the invention will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the description and the drawings. Attached Figure Description

[0009] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below.

[0010] Figure 1 This is a flowchart of a method for processing security test data of a large language model according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of a large language model security test data processing system according to an embodiment of the present invention. Detailed Implementation

[0011] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments.

[0012] In related technologies, ensuring the stable and reliable operation of large language models (LLMs) in the face of various potential threats is crucial during the security assessment and deployment process. To this end, specialized security testing platforms are widely used, which need to process massive amounts of test data to comprehensively explore vulnerabilities in the models. However, with the deepening and increasing complexity of security testing, traditional memory management methods face severe challenges in handling these increasingly diverse and structurally complex test data, as well as concurrent test sessions that require long-term state maintenance. Specifically, test data is no longer in a single text format, but contains multimodal information, highly structured instruction sequences, and adversarial samples with specific internal representations. This data often has strict requirements for memory continuity. Simultaneously, to simulate real attack scenarios, multiple test sessions need to run in parallel, each maintaining its unique context information, which dynamically grows as the session progresses and resides in memory for extended periods. This significant difference in memory request size, lifecycle, and continuity requirements makes existing memory management mechanisms ineffective, easily leading to memory space being fragmented into numerous discontinuous small blocks, i.e., severe external fragmentation. Even if the system has sufficient total memory, the lack of sufficiently large contiguous memory blocks may lead to the failure of critical data allocation, thereby interrupting the testing process and severely affecting the efficiency and depth of security assessment. This results in low memory management reliability and low data processing efficiency.

[0013] For example, in the security testing of large language models (LLMs), traditional static test cases are no longer sufficient to cope with increasingly complex security threats. Testers need to handle new types of test data, such as multimodal inputs (e.g., images, audio), highly structured data (e.g., JSON, XML), and adversarial samples. This data needs to be stored in memory using specific data structures and occupies a large number of contiguous memory blocks. At the same time, the historical dialogue context and intermediate results introduced by concurrent test sessions lead to highly diverse memory allocation requests: significant differences in size (from bytes to GB), varying lifecycles (coexistence of short-lived and long-term resident data), and strict continuity requirements (especially for multimodal data). This fragmented and irregular memory allocation pattern seriously affects testing efficiency. On the one hand, the need for large contiguous memory blocks may cause test interruptions, wasting computing resources and interrupting attack chain simulations; on the other hand, frequent memory defragmentation operations (e.g., defragmentation or garbage collection) consume additional computing resources, introduce time delays, reduce data loading and processing speeds, slow down the test platform, and even extend the test cycle.

[0014] In complex, concurrent, and state-preserving security testing scenarios targeting large language models, the test data exhibits highly heterogeneous characteristics. It includes multimodal or structured data with strict requirements for contiguous memory space, as well as concurrent test session states that need to reside in memory for extended periods. These diverse memory allocation requests vary significantly in size, lifecycle, and continuity requirements, making existing memory management methods ineffective. Specifically, when processing a large number of concurrent and heterogeneous memory requests, the system rapidly generates severe fragmentation, especially when allocating space for large, contiguous data blocks. Even with sufficient total memory, allocation may fail due to a lack of contiguous space, thus interrupting critical testing processes. Therefore, there is a need to efficiently handle complex, concurrent, and state-preserving heterogeneous test data in large language model security testing without interrupting the testing process or introducing significant performance overhead. This requires effectively meeting the allocation needs for large contiguous memory blocks while fundamentally avoiding or significantly mitigating memory fragmentation, thereby ensuring the efficient and stable operation of advanced security testing tasks.

[0015] The embodiments of this application will be explained in detail below with reference to the accompanying drawings: Figure 1 This is an optional flowchart of a method for processing large language model security test data provided in an embodiment of this application. Figure 1 The method may include, but is not limited to, steps S101 to S104.

[0016] Step S101: Obtain test data from the large language model security testing platform. The test data includes multimodal data, structured attack payload data, long-term session state data, and short-term temporary data. Step S102: Based on the test data, the main memory space is divided into regions to obtain multiple initial functional regions. The initial functional regions include multimodal regions, structured attack payload regions, long-term session state regions, or short-term temporary regions. Step S103: Construct a corresponding regional memory management unit in each initial functional area. The regional memory management unit is used to allocate memory according to the memory allocation strategy. Step S104: After memory allocation, the test data is allocated to the corresponding initial functional area for test data processing.

[0017] Steps S101 to S104 shown in the embodiments of this application can combine functional areas and memory allocation strategies to allocate memory, so that the test data has sufficient memory space, thereby realizing test data processing and improving memory management reliability and data processing efficiency.

[0018] In some embodiments, steps S101-S104 may first involve acquiring test data from a large language model security testing platform. This test data includes multimodal data, structured attack payload data, long-term session state data, and short-term temporary data. The test data can be automatically generated by the testing platform, for example, through fuzzing or adversarial sample generation techniques. Alternatively, it can be a pre-prepared dataset, such as a publicly available dataset containing various attack patterns and vulnerability scenarios. During the acquisition process, standard file I / O operations, network transmission protocols, or database queries can be used. For example, the testing platform can read pre-set multimodal data from a file system, receive real-time structured attack payload data from a message queue, or load historical session state data from persistent storage. It is understood that a large language model security testing platform refers to a software system or environment used to evaluate and verify the security performance of large language models. This platform can simulate various attack scenarios and generate diverse test data to discover potential vulnerabilities and weaknesses in the model. Multimodal data refers to non-textual data such as images, audio, and video, which typically have large volumes and high requirements for memory continuity. Structured attack payload data refers to carefully crafted attack instructions or inputs with specific formats and semantics, designed to trigger specific behaviors or vulnerabilities in a model. Long-term session state data refers to contextual information that needs to be continuously maintained during long-term interactive sessions, such as dialogue history, user preferences, and intermediate calculation results; this data has a relatively long lifespan. Short-term temporary data refers to short-lived data generated and used temporarily during testing, such as intermediate variables and temporary buffers.

[0019] Then, based on the test data, the main memory space is divided into regions, resulting in multiple initial functional regions. These initial functional regions include a multimodal region, a structured attack payload region, a long-term session state region, or a short-term temporary region. The main memory space can be divided into multimodal regions, structured attack payload regions, long-term session state regions, and short-term temporary regions. This division can be statically based on a preset memory size ratio; for example, allocating 30% of the total memory to the multimodal region, 20% to the structured attack payload region, 40% to the long-term session state region, and the remaining 10% to the short-term temporary region. Alternatively, the initial size of each region can be dynamically adjusted based on historical data analysis. For example, the initial capacity of each region can be determined by analyzing the average size and peak demand of various test data over a past period. It is understood that main memory space refers to the primary storage area in a computer system used to store programs and data, typically referring to random access memory (RAM).

[0020] Then, a corresponding regional memory management unit is built in each initial functional area. This regional memory management unit is used to allocate memory according to a memory allocation strategy. Each regional memory management unit operates independently and is responsible for memory allocation within its designated area. For example, for a multimodal region, a dedicated regional memory management unit optimized for allocating large contiguous memory blocks can be built to meet the high memory continuity requirements of multimodal data. For short-lived temporary regions, a regional memory management unit optimized for the rapid allocation and deallocation of small memory blocks can be built. These regional memory management units can employ different memory allocation strategies. For example, the memory management unit for a multimodal region can use a buddy system or a slab allocator to efficiently manage large memory blocks. The memory management unit for a short-lived temporary region can use a free list or bitmap management to quickly allocate and reclaim small memory blocks.

[0021] After memory allocation, test data is assigned to the corresponding initial functional area for processing. For example, when multimodal data is acquired, it is allocated to the multimodal area and managed by the memory management unit of that area. The testing platform can perform decoding, feature extraction, and other processing on this multimodal data. When structured attack payload data is acquired, it is allocated to the structured attack payload area and managed by the memory management unit of that area, followed by parsing and execution.

[0022] Through the above technical solution, this embodiment achieves efficient and stable memory management by finely classifying and partitioning test data into memory regions. This embodiment first acquires test data and then partitions the main memory space into multiple initial functional regions based on the characteristics of this data. This partitioning allows different types of data to be managed in isolation, avoiding interference between different memory requirements. Specifically, a corresponding regional memory management unit is constructed in each initial functional region. These regional memory management units allocate memory using customized memory allocation strategies based on the characteristics of the data within their respective regions. In this way, the memory management of each region can adapt to the characteristics of the data it processes to the greatest extent, thereby improving the efficiency and success rate of memory allocation. After memory allocation is completed, the test data is allocated to the corresponding initial functional region for subsequent test data processing. This regionalized management method not only reduces memory fragmentation but also improves the locality of data access, thereby improving cache hit rate and overall system performance. By isolating different types of data in dedicated memory areas and managing them with a customized memory management unit, this embodiment effectively solves the challenges faced by traditional memory management methods when processing large language model security test data, ensuring the smooth progress of the testing process and improving the efficiency and depth of security assessment.

[0023] In some embodiments, in step S103, memory allocation is performed according to a memory allocation strategy, which may include, but is not limited to, the following steps: Step S201: Select one region from multiple initial functional regions as the target functional region; Step S202: Monitor the memory usage and the number of available free memory blocks in the target functional area; Step S203: If the memory usage rate of the target functional area is greater than the preset usage rate threshold and the number of available free memory blocks is less than the preset available threshold, then an idle functional area is identified from multiple initial functional areas, and the memory usage rate of the idle functional area is less than the preset usage rate threshold. Step S204: Adjust the memory capacity of the target functional area according to the memory allocation strategy and the memory capacity of the free functional area.

[0024] In some embodiments, the memory requirements of different types of test data may change dynamically, which may cause the preset memory allocation strategy to be unable to adequately cope with the situation of insufficient or wasted memory resources in certain functional areas, thereby affecting test efficiency and system stability.

[0025] Therefore, one of several initial functional areas can be selected as the target functional area. This selection can be based on the type of test data currently being processed, the historical load of that area, or preset priority rules. For example, when the system detects that an initial functional area is processing a large amount of high-priority or real-time-critical data, that area can be prioritized as the target functional area.

[0026] Then monitor the memory usage and the number of available free memory blocks in the target functional area. Continuously track the ratio of allocated memory to total memory in this area, as well as the number of contiguous memory blocks that have not yet been allocated. Memory usage reflects the memory pressure in this area, while the number of available free memory blocks indicates the area's ability to meet new memory allocation requests without memory defragmentation or expansion.

[0027] If the memory usage rate of the target functional area exceeds a preset usage rate threshold, and the number of available free memory blocks is less than a preset availability threshold, it indicates that the target functional area may face a risk of memory resource shortage. In this case, it is necessary to identify free functional areas from multiple initial functional areas, where the memory usage rate of these free functional areas is less than the preset usage rate threshold, to ensure that they have sufficient redundant memory available for borrowing. The preset usage rate threshold and the preset availability threshold can be configured based on system performance requirements, test data characteristics, and empirical values.

[0028] Finally, based on the memory allocation strategy and the memory capacity of the free functional areas, the memory capacity of the target functional area is adjusted. After identifying the free functional areas, the system dynamically allocates a portion of memory from the free functional areas to the target functional area according to the current memory allocation strategy (e.g., prioritizing high-priority data, maintaining load balance across areas, etc.) and the actual amount of memory that can be borrowed from the free functional areas, thereby alleviating the memory pressure on the target functional area.

[0029] This embodiment effectively solves the resource bottleneck problem that may be caused by static memory allocation by introducing a dynamic memory capacity adjustment mechanism. Specifically, when a target functional area experiences excessive memory usage and insufficient available free memory blocks due to processing a large amount of test data, the system can detect this situation in a timely manner. This real-time monitoring capability allows the system to proactively identify available memory resources from other free functional areas with lower memory usage. By dynamically adjusting these free resources to the memory-constrained target functional areas according to the memory allocation strategy, this embodiment achieves flexible scheduling and optimized configuration of memory resources, avoiding performance degradation or test interruption caused by insufficient memory in a single area.

[0030] To illustrate this technical solution more clearly, a specific example is used below. Suppose a large language model security testing platform is conducting a security vulnerability test targeting multimodal data. At this time, the memory usage of the multimodal region, as the target functional region, may rapidly increase, potentially reaching a preset usage threshold (e.g., 85%), while the number of available free memory blocks may decrease to a preset available threshold (e.g., less than 10 contiguous memory blocks). Upon detecting this situation, the system scans other initial functional regions, such as the structured attack payload region, and finds that its memory usage is far below the preset usage threshold (e.g., 20%), and it possesses a large number of available free memory blocks. At this point, the system dynamically allocates a portion of memory capacity (e.g., 512MB) from the structured attack payload region to the multimodal region according to a preset memory allocation strategy (e.g., prioritizing the smoothness of multimodal data processing). Thus, the memory capacity of the multimodal region is expanded, enabling it to continue processing the influx of multimodal data smoothly without processing delays or errors due to insufficient memory. Once the memory pressure in the multimodal region is relieved, the system can also return the excess memory to the structured attack payload region according to the policy, so as to maintain the balance of overall memory resources.

[0031] Through the above technical solution, this embodiment enables dynamic and efficient management of memory resources during the processing of large language model security test data. This embodiment significantly improves the system's adaptability to fluctuations in memory requirements for different types of test data, effectively avoiding performance bottlenecks caused by localized memory resource shortages, thereby improving the stability and efficiency of the test. Furthermore, by intelligently identifying and utilizing idle memory resources, it optimizes overall memory utilization and reduces unnecessary resource waste.

[0032] In some embodiments, step S202, monitoring the memory usage and the number of available free memory blocks in the target functional area, may include, but is not limited to, the following steps: Retrieve memory allocation and deallocation events for the target functional area; Update the memory usage status of the target functional area based on memory allocation and memory release events; By calling the host machine's virtualization layer interface, the host machine's memory allocation and reclamation events can be obtained; By associating memory usage status with host machine memory allocation and reclamation events, the memory usage rate and the number of available free memory blocks in the target functional area can be obtained.

[0033] In some embodiments, memory allocation and deallocation events of the target functional region can be acquired first. Within the target functional region, all memory request (allocation) and deallocation (deallocation) operations are recorded through its regional memory management unit. These events contain key information such as the size, address, and time of occurrence of the memory blocks.

[0034] Then, based on memory allocation and deallocation events, the memory usage status of the target functional area is updated. A data structure regarding the current memory usage of the target functional area can be maintained in real-time based on recorded events; for example, it could be a bitmap or linked list indicating which memory blocks are occupied and which are free. The purpose is to provide a perspective on memory usage from within the target functional area.

[0035] Then, by calling the host machine's virtualization layer interface, memory allocation and reclamation events of the host machine can be obtained. In a virtualization environment, the target functional area runs as a virtual machine or container on the host machine, and its memory resources are managed and scheduled by the host machine's virtualization layer. Therefore, it is necessary to obtain the allocation and reclamation information of the physical memory corresponding to the target functional area at the host machine level through the interface provided by the host machine. For example, it is possible to obtain how many physical memory pages the host machine has allocated to the target functional area, and how many physical memory pages have been reclaimed. The purpose is to provide a perspective at the host machine level on the actual physical memory usage of the target functional area.

[0036] Finally, the memory usage status is correlated with the host machine's memory allocation and reclamation events to obtain the memory usage rate and the number of available free memory blocks in the target functional area. This means integrating and calibrating the memory usage reported within the target functional area (logical view) with the actual physical memory usage reported by the host machine's virtualization layer (physical view). For example, by comparing the two sets of data, it is possible to more accurately determine the actual amount of physical memory available in the target functional area and whether its memory usage rate truly reflects the occupancy of underlying physical resources. The goal is to obtain a comprehensive, accurate, and consistent view of memory usage, avoiding misjudgments caused by information asymmetry due to the virtualization layer.

[0037] This embodiment combines memory allocation and deallocation events within the target functional region with memory allocation and reclamation events at the host virtualization layer to obtain a more comprehensive and accurate view of memory usage. Specifically, events within the target functional region reflect its logical memory requirements and usage patterns, while events at the host virtualization layer reveal the actual allocation and reclamation of underlying physical memory. By correlating these two types of information, potential biases from a single perspective can be effectively mitigated. For example, the target functional region might perceive itself as having a large amount of free memory, but the host might have already reclaimed or allocated the corresponding physical memory to other virtual machines. This dual monitoring mechanism ensures accurate assessment of the target functional region's memory utilization and the number of available free memory blocks, providing a reliable data foundation for subsequent memory capacity adjustments.

[0038] By employing the above technical solution, this embodiment overcomes the limitations of relying solely on a single layer (such as relying only on internal virtual machine reports or only on host machine reports) for memory monitoring. This embodiment integrates internal and external memory events to achieve refined and accurate monitoring of memory usage in target functional areas. Especially in virtualized environments, it effectively avoids memory information asymmetry caused by virtualization layer abstraction. Therefore, it can more accurately determine whether a target functional area truly requires memory capacity adjustment, thereby improving the efficiency and accuracy of memory resource management, avoiding unnecessary memory adjustment operations, or promptly identifying and resolving potential memory resource bottlenecks.

[0039] In some embodiments, identifying idle functional regions from multiple initial functional regions in step S203 may include, but is not limited to, the following steps: A corresponding memory demand prediction unit is established in each initial functional area. The memory demand prediction unit is used to predict memory demand trends based on the historical memory usage patterns of the initial functional area. A corresponding memory borrowing capacity assessment unit is established in each initial functional area. The memory borrowing capacity assessment unit is used to calculate the amount of memory that can be borrowed based on the current total amount of free memory, the maximum size of the contiguous free block, and the memory demand trend of the initial functional area. Based on memory demand trends and available memory size, multiple initial functional areas are sorted to obtain the functional area sorting result; The functional area that appears first in the sorting results is designated as the free functional area.

[0040] In some embodiments, identifying free functional regions solely based on current memory usage may not adequately account for future memory demand trends in those regions and the actual availability of their memory blocks. This could lead to selected free functional regions facing memory shortages again in the short term, or their free memory blocks becoming unsuitable for borrowing, thus impacting the efficiency and stability of memory adjustments.

[0041] To address this, a corresponding memory demand prediction unit can be established in each initial functional region. This unit predicts memory demand trends based on the historical memory usage patterns of that initial functional region. The main function of the memory demand prediction unit is to use machine learning algorithms or statistical models to predict future memory demand trends for that region, based on its historical memory usage patterns, such as peak memory allocation, average usage, and release frequency over a past period. This prediction helps the system anticipate changes in memory pressure in each region, thereby enabling more forward-looking decision-making.

[0042] Then, a corresponding memory borrowing capability assessment unit is established in each initial functional area. This unit calculates the amount of memory that can be borrowed based on the current total free memory, the maximum contiguous free block size, and memory demand trends of the initial functional area. The role of the memory borrowing capability assessment unit is to comprehensively evaluate the actual ability of that area to borrow memory from other areas. This assessment unit considers the current total free memory, i.e., the total available memory space in that area; the maximum contiguous free block size, which is crucial for data types requiring large contiguous memory blocks (such as multimodal data); and the memory demand trend provided by the memory demand prediction unit. Using these parameters, the memory borrowing capability assessment unit can calculate the amount of memory that the area can safely borrow without affecting its future normal operation.

[0043] Then, based on memory demand trends and available lent memory size, the initial functional areas are sorted to obtain the functional area ranking result. The sorting is based on a comprehensive consideration of the memory demand trend of each area (e.g., the lower the demand trend, the more suitable it is to lend) and the available lent memory size (the larger the available lent memory, the more suitable it is to lend). For example, a scoring function can be designed to calculate a weighted average of demand trend and available lent memory size to obtain a comprehensive score. Based on this score, all initial functional areas are sorted in descending or ascending order to obtain the functional area ranking result.

[0044] Finally, the functional area that appears first in the functional area sorting results is selected as the free functional area. This means that the selected free functional area not only has a low current memory usage rate, but also a relatively stable future memory demand trend, and has a large memory capacity suitable for lending, thus ensuring the effectiveness and stability of memory adjustment.

[0045] This embodiment optimizes the process of identifying idle functional regions by introducing a memory demand prediction unit and a memory borrowing capability assessment unit. Specifically, when memory resources in the target functional region are scarce, the system no longer relies solely on the current memory usage rate to determine whether other regions are "idle." Instead, the memory demand prediction unit proactively analyzes the historical memory usage patterns of each initial functional region to predict its future memory demand trends. This allows the system to avoid incorrectly identifying regions that are about to face memory pressure as idle regions. Simultaneously, the memory borrowing capability assessment unit accurately calculates the actual amount of memory that can be borrowed from each region based on the current total amount of free memory, the maximum size of contiguous free blocks, and the predicted memory demand trends. This assessment process ensures that the selected idle functional regions not only have sufficient free memory, but also that the contiguousness of these memory blocks meets the potential borrowing needs, and that borrowing memory will not negatively impact their future operation. By comprehensively ranking this information, the system can intelligently select the most suitable candidates as idle functional regions, thereby providing stable and efficient memory replenishment to the target functional region.

[0046] To illustrate this technical solution more clearly, a specific example is used below. Assume there are three initial functional areas in the large language model security testing platform: a multimodal area, a structured attack payload area, and a long-term session state area. Currently, the memory usage rate of the structured attack payload area has exceeded a preset usage threshold, and the number of available free memory blocks is lower than a preset availability threshold, requiring memory to be borrowed from other areas. At this point, the system initiates a process to identify free functional areas: First, in the multimodal area, structured attack payload area, and long-term session state area, the respective memory demand prediction unit makes predictions based on their historical memory usage patterns. For example, historical data for the multimodal area shows lower memory demand at night, while the long-term session state area shows relatively stable memory demand during daytime working hours. Next, in each area, the memory borrowing capacity assessment unit calculates the amount of memory that can be borrowed based on the current total amount of free memory, the maximum contiguous free block size, and the predicted memory demand trend. For example, the multimodal area currently has a large amount of free memory, and its predicted future demand is low; its available memory size is assessed as 5GB, including a 3GB contiguous free block. Although there is also free memory in the long-term session state area, its predicted demand is relatively stable and the free memory blocks are relatively scattered. Its available memory size is estimated to be 2GB, and the maximum contiguous free block is 500MB.

[0047] The system then sorts these three initial functional regions based on memory demand trends and available loanable memory. Assuming the sorting results show the multimodal region has the highest overall score (due to its low demand trend and high available loanable memory), followed by the long-lived session state region, the system ultimately identifies the multimodal region, ranked first in the functional region sorting, as the idle functional region. Subsequently, the system adjusts the memory capacity of the structured attack payload region based on memory allocation strategies and the memory capacity of the multimodal region, for example, allocating a portion of memory from the multimodal region to the structured attack payload region. This ensures that the selected idle functional region is the most suitable for providing memory support, thereby optimizing the dynamic management of memory resources.

[0048] Through the above technical solution, this embodiment overcomes the limitation of identifying free areas solely based on current memory usage. By leveraging the forward-looking analysis of the memory demand prediction unit, it effectively avoids misclassifying areas that will soon be busy as free areas, thereby reducing system overhead caused by frequent memory adjustments. Simultaneously, the introduction of the memory borrowing capability assessment unit ensures that the selected free functional area not only has sufficient memory capacity but also that the continuity of its memory blocks meets actual needs, improving the efficiency and quality of memory borrowing. Therefore, this embodiment achieves more intelligent, stable, and efficient memory resource scheduling, significantly improving the overall performance and reliability of large language model security test data processing.

[0049] In some embodiments, step S204, adjusting the memory capacity of the target functional region according to the memory allocation strategy and the memory capacity of the free functional region, may include, but is not limited to, the following steps: Query the host machine's virtualization layer for the memory block lock status of the free functional area; If the memory block is locked, an unlock request is sent to the host virtualization layer. The host virtualization layer then unlocks the free functional area of ​​memory based on the unlock request. After the memory is unlocked, memory blocks in the free functional area are allocated to the target functional area according to the memory allocation policy and the memory capacity of the free functional area.

[0050] In some embodiments, because memory blocks in free functional regions may be locked by the host virtualization layer, direct adjustment of memory capacity is impossible, thus affecting the efficiency of dynamic memory resource allocation and system flexibility. Therefore, the host virtualization layer can be queried for the locking status of memory blocks in free functional regions. The host virtualization layer is a core component managing physical and virtual memory allocation, and it may lock certain memory blocks for security, performance, or resource isolation purposes. The query operation aims to determine whether these memory blocks are available.

[0051] If the memory block is locked, an unlock request is sent to the host virtualization layer. The host virtualization layer then unlocks the memory in the free functional area based on the unlock request. This unlock request instructs the host virtualization layer to release the lock on a specific memory block in the free functional area. After receiving and processing the unlock request, the host virtualization layer performs the corresponding memory unlock operation, making the previously locked memory block available for allocation.

[0052] After memory unlocking, memory blocks in the free functional area are allocated to the target functional area according to the memory allocation strategy and the memory capacity of the free functional area. After the memory unlocking operation is complete, the system will select and allocate the required memory blocks from the free functional area to the target functional area based on the preset memory allocation strategy and the actual memory capacity of the free functional area. This process ensures the efficient transfer of memory resources and the dynamic expansion or contraction of the target functional area's memory capacity, thereby meeting the real-time memory requirements for processing large language model security test data.

[0053] This embodiment effectively solves the problem of locked memory blocks in free functional areas preventing memory capacity adjustment by introducing a query and unlock mechanism for the locked status of memory blocks in the host virtualization layer. When the target functional area needs to expand memory and a free functional area has been identified, the host virtualization layer is first queried to determine whether the memory blocks in the free functional area are locked. This avoids failures caused by blindly attempting allocation when memory is locked. If a memory block is found to be locked, an unlock request is actively sent to the host virtualization layer, prompting the host virtualization layer to release control over these memory blocks. After receiving and responding to the unlock request, the host virtualization layer changes the memory block status from locked to available, thus clearing the way for subsequent memory allocation operations. Finally, after the memory block is successfully unlocked, the system can smoothly allocate the available memory blocks in the free functional area to the target functional area according to the established memory allocation strategy, realizing flexible allocation and dynamic management of memory resources.

[0054] To illustrate this technical solution more clearly, a specific example is used below. Suppose that the memory usage of a target functional area (e.g., the area used to process structured attack payload data) in a large language model security testing platform has reached a preset usage threshold, and the number of available free memory blocks is lower than a preset availability threshold, requiring more memory to be obtained from other free functional areas. The system identifies a free functional area with low memory usage, theoretically from which memory can be borrowed. However, before attempting to adjust the memory capacity of the target functional area, the system first queries the host virtualization layer for the memory block lock status of this free functional area.

[0055] Specifically, if the query results show that certain memory blocks in the free functional area are locked by the host virtualization layer (e.g., due to maintenance operations or resource isolation policies on the host), the system will not attempt to allocate them directly. Instead, it will immediately send an unlock request to the host virtualization layer, explicitly specifying the specific memory blocks in the free functional area that need to be unlocked. After verifying the request, the host virtualization layer will perform a memory unlock operation, releasing these memory blocks from their locked state. Once the memory unlock is complete, the system will allocate the required number of memory blocks from the unlocked free functional area to the target functional area according to the current memory allocation policy. For example, one or more physically contiguous memory page groups can be allocated to meet the target functional area's memory contiguity requirements. Through this series of operations, the memory capacity of the target functional area is successfully expanded, ensuring the smooth processing of structured attack payload data and avoiding test interruptions or performance degradation due to insufficient memory.

[0056] Through the above technical solution, this embodiment ensures that even if the memory blocks of idle functional areas are locked by the host virtualization layer during the processing of large language model security test data, the memory capacity of the target functional area can be dynamically adjusted through an active query and unlock mechanism. This significantly improves the flexibility and reliability of memory resource scheduling, avoiding resource waste or performance bottlenecks caused by memory locking. Furthermore, this embodiment optimizes the success rate of memory allocation, enabling the system to respond more efficiently to real-time changes in the memory requirements of test data, thereby improving the overall operating efficiency and stability of the large language model security testing platform.

[0057] In some embodiments, in step S103, memory allocation is performed according to a memory allocation strategy, which may include, but is not limited to, the following steps: Step S301: Obtain the current memory access mode; Step S302: Build a corresponding memory access mode monitor in each initial functional area. The memory access mode monitor is used to record the memory access parameters in the initial functional area. The memory access parameters include memory allocation request size, memory allocation request frequency and memory release mode. Step S303: Evaluate the overall matching score between the memory allocation strategy and the current memory access mode; Step S304: If the overall matching score is less than the preset matching threshold, then update the memory allocation strategy according to the memory access parameters and the memory access strategy set; Step S305: Allocate memory according to the updated memory allocation strategy.

[0058] In some embodiments, the type and access patterns of test data can be complex and varied. For example, multimodal data may require large blocks of contiguous memory, while structured attack payload data may involve a large number of small and frequent memory allocations and releases. If the memory allocation strategy is statically preset, it may be difficult to effectively adapt to these dynamically changing memory access patterns, resulting in low memory resource utilization, increased memory fragmentation, or performance bottlenecks.

[0059] To do this, we can first obtain the current memory access pattern. We can monitor and collect the characteristics of ongoing memory operations in real time, such as the type, size, frequency, and release pattern of memory requests. These patterns reflect the memory resource requirements of the current test data.

[0060] Then, a corresponding memory access pattern monitor is built for each initial functional region. The memory access pattern monitor records the memory access parameters within the initial functional region. These parameters include memory allocation request size, memory allocation request frequency, and memory release mode. Memory allocation request size refers to the size of the memory block requested in each memory allocation operation; memory allocation request frequency refers to the number of memory allocation requests occurring per unit of time; and memory release mode refers to the method and timing of memory block release, such as immediate or delayed release. These parameters collectively depict the memory usage dynamics of that initial functional region.

[0061] The overall matching score between the memory allocation strategy and the current memory access pattern is then evaluated. Specific algorithms or models can quantify the degree of fit between the currently used memory allocation strategy and the real-time monitored memory access pattern. A higher score indicates that the current strategy is more suitable for the current memory access pattern. If the overall matching score is lower than a preset matching threshold, it indicates that the current memory allocation strategy is no longer suitable for the current memory access pattern and needs adjustment. In this case, a better memory allocation strategy can be selected or generated to replace the current strategy based on memory access parameters (such as request size, frequency, and release mode) and the memory access strategy set. The memory access strategy set can contain multiple strategies optimized for different memory access patterns, such as strategies for allocating large contiguous memory blocks or strategies for frequently allocated small blocks. Finally, memory allocation is performed according to the updated memory allocation strategy to ensure continuous optimization of memory resource allocation.

[0062] This embodiment addresses the inefficiency of static memory allocation strategies when faced with dynamically changing test data access patterns by introducing a dynamic monitoring and strategy update mechanism. Specifically, a memory access pattern monitor continuously collects memory access parameters for each initial functional area, enabling the system to monitor memory usage in real time. By evaluating the comprehensive matching score between the current memory allocation strategy and the real-time access pattern, the system can determine the applicability of the current strategy. When the matching score falls below a preset threshold, it indicates that the current strategy is no longer the optimal choice. At this point, the system selects or generates a new strategy that better suits the current access pattern from a preset set of memory access strategies based on the collected memory access parameters. This dynamic adjustment mechanism ensures that the memory allocation strategy can adaptively optimize as the characteristics of the test data and access patterns change, thereby avoiding memory resource waste and performance degradation caused by strategy mismatch.

[0063] To illustrate this technical solution more clearly, a specific example is used below. Suppose a large language model security testing platform is processing two distinct types of test data: one is multimodal data requiring large amounts of contiguous memory for video stream processing, and the other is structured attack payload data involving frequent creation and destruction of small objects. Initially, the system might employ a general memory allocation strategy. As multimodal data begins to flood in, the memory access pattern monitor records high-frequency large memory allocation requests and long memory lifetimes. At this point, the evaluation module finds that the current general strategy has a low overall match score with this "large contiguous allocation" pattern because it may lead to memory fragmentation, making it difficult to meet the contiguous memory requirements of multimodal data. Based on these memory access parameters, the system selects or generates a strategy specifically optimized for large contiguous memory allocation from the set of memory access strategies, such as using a buddy system or a slab allocator, and updates the current memory allocation strategy.

[0064] Subsequently, when the test scenario switched to structured attack payload data, the monitor recorded high-frequency small memory allocation requests and short memory lifecycles. At this point, the system re-evaluated and found that the current strategy optimized for large memory blocks had a low match score with the "frequent small block allocation" pattern. The system then updated the memory allocation strategy again, selecting a strategy more suitable for the rapid allocation and reclamation of small objects, such as using a memory pool or a custom allocator. Through this dynamic adjustment, the system can always maintain a high degree of match between the memory allocation strategy and the memory access patterns of the current test data, thereby ensuring optimal utilization of memory resources and avoiding performance bottlenecks or resource waste caused by strategy mismatch.

[0065] Through the above technical solution, this embodiment enables dynamic adaptive adjustment of memory allocation strategies, significantly improving the flexibility and efficiency of memory resource utilization during the processing of large language model security test data. This embodiment can better address the differences in memory access patterns among different types of test data (such as multimodal data, structured attack payload data, long-term session state data, and short-term temporary data), effectively reducing memory fragmentation and optimizing memory access performance. Therefore, the system can select the most suitable memory allocation strategy based on real-time load and data characteristics, thereby improving the overall operating efficiency and stability of the testing platform.

[0066] In some embodiments, step S303, evaluating the overall matching score between the memory allocation strategy and the current memory access mode, may include, but is not limited to, the following steps: Step S401: Obtain the differential requirements corresponding to each type of test data. The differential requirements include memory continuity, data lifecycle, and access frequency. Step S402: Based on the current memory access mode and differentiated requirements, set the memory allocation strategy optimization target for each type of test data; Step S403: Based on the memory access parameters, evaluate the optimization score of the memory allocation strategy on the memory allocation strategy optimization objective; Step S404: Calculate the overall matching score based on the optimization score and test load percentage corresponding to each type of test data.

[0067] In some embodiments, the differentiated requirements for each type of test data can be obtained first. These differentiated requirements include memory continuity, data lifecycle, and access frequency. Differentiated requirements refer to the unique needs and characteristics of different types of test data in terms of memory usage. For example, multimodal data may have high requirements for memory continuity to ensure smooth data flow processing; structured attack payload data may have specific requirements for data lifecycle, such as rapid allocation and release within a short period; and long-term session state data may have high requirements for access frequency, requiring fast access. These differentiated requirements can be predefined or obtained by analyzing historical data.

[0068] Then, based on the current memory access patterns and differentiated requirements, optimization goals for memory allocation strategies are set for each type of test data. Memory allocation strategy optimization goals refer to specific objectives set for each type of test data based on these differentiated requirements, aimed at improving memory allocation efficiency and performance. For example, for data requiring high memory contiguity, the optimization goal could be to maximize the allocation of contiguous memory blocks; for short-lived data, the optimization goal could be to minimize memory fragmentation.

[0069] Next, based on memory access parameters, evaluate the optimization score of the memory allocation strategy on its optimization objective. The optimization score refers to the evaluation of the current memory allocation strategy's performance in meeting a specific optimization objective, which can be calculated by comparing the actual allocation effect with the optimization objective.

[0070] Finally, the overall matching score is calculated based on the optimization score and test load percentage for each type of test data. The test load percentage refers to the proportion of resources or processing time occupied by different types of test data in the overall test task. This helps to reasonably weight the optimization scores of different data when calculating the overall matching score.

[0071] This embodiment first identifies and acquires the unique requirements of each type of test data, thereby enabling the targeted setting of memory allocation strategy optimization goals. Subsequently, based on memory access parameters, the effectiveness of the current memory allocation strategy in achieving these optimization goals is quantitatively evaluated, resulting in an optimization score. Finally, by combining the optimization scores of each type of test data with their proportion in the overall test load, a weighted comprehensive matching score is calculated. Therefore, this embodiment can comprehensively and precisely measure the degree of matching between the current memory allocation strategy and the actual memory access pattern, providing an accurate basis for subsequent updates to the memory allocation strategy.

[0072] Through the above technical solution, this embodiment can achieve a refined evaluation of the matching degree between memory allocation strategies and current memory access patterns. This evaluation process fully considers the differentiated needs of different test data, enabling the comprehensive matching score to more accurately reflect the actual performance and applicability of the memory allocation strategy. This helps avoid strategy bias caused by a single indicator evaluation, thus providing a more reliable and comprehensive decision-making basis for the dynamic adjustment of memory allocation strategies, thereby improving the overall efficiency and stability of large language model security test data processing.

[0073] In some embodiments, step S404, calculating the comprehensive matching score based on the optimization score and test load percentage corresponding to each type of test data, may include, but is not limited to, the following steps: Obtain the real-time memory request volume and processing time corresponding to each type of test data; Assess the range of memory load fluctuations based on real-time memory request volume and processing time; The memory weighting factor is determined based on the test load percentage, memory load fluctuation range, real-time memory request volume, and processing time. Based on the memory weight factor corresponding to each type of test data, the optimization scores corresponding to each type of test data are weighted and fused to obtain a comprehensive matching score.

[0074] In some embodiments, since the memory request volume and processing time of test data may fluctuate dynamically, relying solely on the static test load ratio for calculation may not accurately reflect the current system's real memory pressure and resource requirements, resulting in an inaccurate matching degree of the memory allocation strategy.

[0075] To do this, we can first obtain the real-time memory request volume and processing time for each type of test data. Real-time memory request volume refers to the total amount of memory allocation requests issued to the system by a certain type of test data within a specific time window, reflecting the immediate demand intensity of memory resources for that data type. Processing time refers to the time required to process specific test data, reflecting the dependence of that data type on computing resources and memory access efficiency. This real-time data can be obtained through system-level performance monitoring tools, memory allocator logs, or custom probes.

[0076] Then, based on the real-time memory request volume and processing time, the memory load fluctuation range is assessed. The memory load fluctuation range refers to the magnitude of change in real-time memory request volume and processing time over a period of time. It can be assessed, for example, by calculating the standard deviation, peak-to-valley difference, or using a moving average, with the aim of quantifying the dynamics and uncertainty of memory demand.

[0077] Then, based on the test load percentage, memory load fluctuation range, real-time memory request volume, and processing time, the memory weight factor is determined. The memory weight factor is a coefficient used to adjust the influence of each test data optimization score. Its determination comprehensively considers multiple dynamic and static parameters such as test load percentage, memory load fluctuation range, real-time memory request volume, and processing time, aiming to more accurately reflect the actual needs and priorities of different test data for memory allocation strategies under the current system state.

[0078] Finally, based on the memory weight factor corresponding to each type of test data, the optimization scores corresponding to each type of test data are weighted and fused to obtain the comprehensive matching score. Weighted fusion refers to summing or averaging the optimization scores corresponding to each type of test data according to their corresponding memory weight factor to obtain the final comprehensive matching score.

[0079] To illustrate this technical solution more clearly, a specific example is used below. Assume a large language model security testing platform is processing two types of test data: multimodal data and structured attack payload data. First, the system continuously acquires the real-time memory request volume and processing time for both multimodal and structured attack payload data. For example, within a certain time period, the real-time memory request volume for multimodal data may suddenly increase, and the processing time may lengthen, while the request volume and processing time for structured attack payload data may remain relatively stable. Based on this real-time data, the system will assess that the memory load fluctuation range for multimodal data is larger, while the fluctuation range for structured attack payload data is smaller.

[0080] Subsequently, based on the preset test load percentage, real-time memory request volume, processing time, and the assessed range of memory load fluctuations, the system determines a memory weight factor for both multimodal data and structured attack payload data. For example, because multimodal data currently has a more urgent and volatile memory requirement, its memory weight factor may be set higher. Finally, the optimization scores of the multimodal data and structured attack payload data are weighted and fused according to their corresponding memory weight factors to calculate the final comprehensive matching score. In this way, even if the optimization score of multimodal data is slightly lower in some aspects, its higher memory weight factor will have a greater impact on the final comprehensive matching score, thereby guiding the system to adjust its memory allocation strategy to better meet the real-time memory requirements of multimodal data.

[0081] Through the above technical solution, the calculation accuracy of the comprehensive matching score in this embodiment is significantly improved, enabling it to more accurately reflect the degree of matching between the memory allocation strategy and the current memory access mode. This allows the system to better cope with the complex and ever-changing memory requirements during large language model security testing, effectively avoiding performance bottlenecks or resource waste caused by improper memory allocation. Furthermore, by dynamically adjusting the memory weight factor, the system can more flexibly adapt to the characteristics of different test data and real-time load changes, thereby optimizing the overall memory resource utilization efficiency and test data processing performance.

[0082] In some embodiments, after dividing the main memory space into regions based on test data to obtain multiple initial functional regions in step S102, the method may also include, but is not limited to, the following steps: Based on multimodal data, the current fragmentation level of the system's physical memory, and multimodal regions, obtain multiple physically contiguous memory page groups; Configure an input / output memory management unit and a direct memory access control unit according to the target hardware acceleration unit; A single, logically contiguous direct memory access virtual address space is created based on multiple physically contiguous memory page groups. When storing data, the multimodal data is stored in the direct memory access virtual address space through the input / output memory management unit; When accessing data, multimodal data is read from the direct memory access virtual address space through the direct memory access control unit.

[0083] In some embodiments, multiple physically contiguous memory page groups can be obtained first based on the multimodal data, the fragmentation level of the current system's physical memory, and the multimodal region. A series of physically contiguous memory pages can be located and allocated within the pre-defined multimodal region, based on the size and characteristics of the multimodal data to be processed, combined with the fragmentation level of the current system's physical memory. The purpose is to provide a contiguous physical storage space for the multimodal data to meet the needs of the hardware acceleration unit for efficient direct memory access (DMA) and to avoid performance degradation caused by memory discontinuity. For example, the allocation of physically contiguous memory can be achieved through mechanisms such as a memory buddy system or reserved large page memory.

[0084] Then, based on the target hardware acceleration unit, the Input / Output Memory Management Unit (IOMMU) and Direct Memory Access Control Unit (DMAC) are configured. For specific target hardware acceleration units, such as graphics processing units (GPUs), network interface cards (NICs), or dedicated video codecs, their corresponding IOMMUs and DMACs are initialized and configured. The IOMMU translates virtual address requests from the hardware acceleration unit into physical addresses and provides memory protection and address translation functions. The DMAC coordinates data transfer between the hardware acceleration unit and main memory, enabling direct data transfer without central processing unit intervention. Its purpose is to provide a secure and efficient memory access mechanism for the hardware acceleration unit and optimize data transfer paths.

[0085] Then, based on multiple physically contiguous memory page groups, a single and logically contiguous direct memory access virtual address space is created. After acquiring multiple physically contiguous memory page groups, the I / O memory management unit maps these physically contiguous memory pages into a single, logically contiguous virtual address space for the hardware acceleration unit. Although these physical pages may be contiguous in physical address space, the mapping by the I / O memory management unit provides the hardware acceleration unit with a unified and simplified address view. The purpose is to simplify the programming model of the hardware acceleration unit, enabling it to access multimodal data as if it were accessing contiguous memory, without needing to concern itself with the underlying physical memory layout.

[0086] During data storage, the Input / Output Memory Management Unit (I / O Memory Management Unit) stores multimodal data in the Direct Memory Access (DMI) virtual address space. When multimodal data needs to be written to memory, the hardware acceleration unit sends a write request to the I / O Memory Management Unit via its DMI mechanism. The I / O Memory Management Unit then translates the virtual address provided by the hardware acceleration unit into the corresponding physical address based on the mapping relationship and writes the multimodal data to the memory page pointed to by that physical address. This ensures that multimodal data can be efficiently and securely stored in a memory region optimized for DMI.

[0087] During data access, multimodal data is read from the direct memory access virtual address space via the direct memory access control unit (DMI). When the hardware acceleration unit needs to read multimodal data, it can initiate a read request through the DMI control unit. The DMI control unit coordinates the data transfer from main memory to the hardware acceleration unit, uses the input / output memory management unit (I / O unit) for address translation, directly reads data from the corresponding physical memory page, and transmits it to the hardware acceleration unit. The purpose is to achieve high-speed reading of multimodal data, reduce CPU intervention, and thus improve data processing efficiency.

[0088] To illustrate this technical solution more clearly, a specific example is used below. Suppose that in a large language model security testing platform, a large amount of video stream data needs to be analyzed in real time to detect potential security vulnerabilities or malicious content. This video stream data is identified as multimodal data and needs to be processed by a dedicated video processing hardware acceleration unit. First, the system dynamically searches for and allocates multiple physically contiguous memory page groups in a pre-defined multimodal region, based on the size of the video stream data and the current fragmentation of physical memory. For example, if a video frame requires 1MB of memory, the system might allocate 256 physically contiguous pages of 4KB each. Next, for this video processing hardware acceleration unit, the system configures its corresponding input / output memory management unit and direct memory access control unit. The input / output memory management unit is configured to map these physically contiguous memory page groups to a single, logically contiguous direct memory access virtual address space, such as a contiguous address range starting from 0x80000000.

[0089] When the video processing hardware acceleration unit needs to store processed video frames back to main memory, it writes the data to a specific address in the Direct Memory Access (DMI) virtual address space via the Input / Output Memory Management (I / O) unit. The I / O Memory Management (I / O) unit then translates this virtual address into the corresponding physical address and stores the data in physical memory. Conversely, when the video processing hardware acceleration unit needs to read raw video frames from main memory for processing, it reads the data from the DMI virtual address space via the DMI control unit. The DMI control unit coordinates the data transfer from physical memory to the hardware acceleration unit, ensuring that data is read as quickly as possible. In this way, the video processing hardware acceleration unit can efficiently and seamlessly access video stream data, avoiding performance bottlenecks caused by discontinuous memory access, thereby ensuring the real-time performance and accuracy of video stream security testing.

[0090] Through the above technical solution, this embodiment significantly improves the processing efficiency and performance of multimodal data in the large language model security testing platform. Since multimodal data is stored in physically contiguous memory page groups and mapped to a logically contiguous direct memory access virtual address space, the hardware acceleration unit can utilize the direct memory access mechanism for high-speed data transmission, effectively avoiding performance bottlenecks caused by memory fragmentation. This not only reduces data transmission latency and improves the utilization rate of the hardware acceleration unit, but also reduces the burden on the central processing unit during data transmission, allowing it to focus on other computational tasks. Furthermore, the introduction of the input / output memory management unit enhances memory access security, preventing the hardware acceleration unit from illegally accessing memory regions. This embodiment provides a solid foundation for efficient and real-time processing of multimodal data in large language model security testing, thereby improving the overall response speed and processing capacity of the testing platform.

[0091] The beneficial effects of implementing the embodiments of the present invention include: First, the embodiments of this application obtain test data in the large language model security testing platform. Then, based on the test data, the main memory space is divided into regions to obtain multiple initial functional regions. Next, a corresponding regional memory management unit is constructed in each initial functional region. Memory is allocated through the regional memory management unit according to the memory allocation strategy. Finally, the test data is allocated to the corresponding initial functional region for test data processing. This allows for memory allocation by combining functional regions and memory allocation strategies, ensuring that the test data has sufficient memory space, thereby realizing test data processing and improving memory management reliability and data processing efficiency.

[0092] like Figure 2 As shown in the figure, this embodiment of the invention also provides a large language model security test data processing system, including: The data acquisition module 501 is used to acquire test data from the large language model security testing platform. The test data includes multimodal data, structured attack payload data, long-term session state data, and short-term temporary data. The region partitioning module 502 is used to partition the main memory space into regions based on the test data to obtain multiple initial functional regions. The initial functional regions include multimodal regions, structured attack payload regions, long-term session state regions, or short-term temporary regions. The memory allocation module 503 is used to build a corresponding regional memory management unit in each initial functional area. The regional memory management unit is used to allocate memory according to the memory allocation strategy. The data allocation module 504 is used to allocate test data to the corresponding initial functional area after memory allocation for test data processing.

[0093] The content of the above method embodiments is applicable to this system embodiment. The specific functions implemented in this system embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0094] The embodiments described in this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

Claims

1. A method for processing security test data of a large language model, characterized in that, Includes the following steps: Acquire test data from the large language model security testing platform, including multimodal data, structured attack payload data, long-term session state data, and short-term temporary data; Based on the test data, the main memory space is divided into regions to obtain multiple initial functional regions, including a multimodal region, a structured attack payload region, a long-term session state region, or a short-term temporary region. A corresponding regional memory management unit is constructed in each initial functional area. The regional memory management unit is used to allocate memory according to the memory allocation strategy. After memory allocation, the test data is assigned to the corresponding initial functional area for test data processing.

2. The method according to claim 1, characterized in that, The process of allocating memory according to a memory allocation strategy includes: Select one region from the plurality of initial functional regions as the target functional region; Monitor the memory usage and the number of available free memory blocks in the target functional area; If the memory usage rate of the target functional area is greater than a preset usage rate threshold, and the number of available free memory blocks is less than a preset available threshold, then an idle functional area is identified from the plurality of initial functional areas, and the memory usage rate of the idle functional area is less than the preset usage rate threshold; The memory capacity of the target functional area is adjusted according to the memory allocation strategy and the memory capacity of the free functional area.

3. The method according to claim 2, characterized in that, The monitoring of memory usage and the number of available free memory blocks in the target functional area includes: Obtain the memory allocation and memory release events of the target functional area; Update the memory usage status of the target functional area based on the memory allocation event and the memory release event; By calling the host machine's virtualization layer interface, the host machine's memory allocation and reclamation events can be obtained; By associating the memory usage status with the host machine's memory allocation and reclamation events, the memory usage rate and the number of available free memory blocks of the target functional area can be obtained.

4. The method according to claim 2, characterized in that, The step of identifying idle functional regions from the plurality of initial functional regions includes: A corresponding memory demand prediction unit is established in each initial functional area. The memory demand prediction unit is used to predict memory demand trends based on the historical memory usage patterns of the initial functional area. A corresponding memory borrowing capacity assessment unit is established in each initial functional area. The memory borrowing capacity assessment unit is used to calculate the amount of memory that can be borrowed based on the current total amount of free memory, the maximum size of the largest contiguous free block, and the memory demand trend of the initial functional area. Based on the memory demand trend and the available memory size, the multiple initial functional areas are sorted to obtain the functional area sorting result; The functional area that appears first in the sorting results is taken as the free functional area.

5. The method according to claim 2, characterized in that, The step of adjusting the memory capacity of the target functional region according to the memory allocation strategy and the memory capacity of the free functional region includes: Query the host virtualization layer for the memory block lock status of the free functional area; If the memory block is locked, an unlock request is sent to the host virtualization layer, which is used to unlock the memory of the free functional area according to the unlock request. After the memory is unlocked, the memory blocks in the free functional area are allocated to the target functional area according to the memory allocation strategy and the memory capacity of the free functional area.

6. The method according to claim 1, characterized in that, The process of allocating memory according to a memory allocation strategy includes: Get the current memory access mode; A corresponding memory access pattern monitor is built in each initial functional area. The memory access pattern monitor is used to record the memory access parameters in the initial functional area. The memory access parameters include memory allocation request size, memory allocation request frequency and memory release mode. Evaluate the overall matching score between the memory allocation strategy and the current memory access pattern; If the overall matching score is less than the preset matching threshold, the memory allocation strategy is updated according to the memory access parameters and the memory access strategy set. Memory allocation is performed according to the updated memory allocation strategy.

7. The method according to claim 6, characterized in that, The evaluation of the overall matching score between the memory allocation strategy and the current memory access mode includes: Obtain the differentiated requirements corresponding to each type of test data, including memory continuity, data lifecycle, and access frequency; Based on the current memory access pattern and the differentiated requirements, set the memory allocation strategy optimization target for each type of test data; Based on the memory access parameters, evaluate the optimization score of the memory allocation strategy on the optimization objective of the memory allocation strategy; The comprehensive matching score is calculated based on the optimization score and test load percentage corresponding to each type of test data.

8. The method according to claim 7, characterized in that, The step of calculating the comprehensive matching score based on the optimization score and test load percentage corresponding to each type of test data includes: Obtain the real-time memory request volume and processing time corresponding to each type of test data; The range of memory load fluctuations is assessed based on the real-time memory request volume and the processing time. The memory weighting factor is determined based on the test load percentage, the memory load fluctuation range, the real-time memory request volume, and the processing time. Based on the memory weight factor corresponding to each type of test data, the optimization scores corresponding to each type of test data are weighted and fused to obtain the comprehensive matching score.

9. The method according to claim 1, characterized in that, After dividing the main memory space into regions based on the test data to obtain multiple initial functional regions, the method further includes: Based on the multimodal data, the current fragmentation level of the system's physical memory, and the multimodal region, obtain multiple physically contiguous memory page groups; Configure an input / output memory management unit and a direct memory access control unit according to the target hardware acceleration unit; Based on the multiple physically contiguous memory page groups, a single and logically contiguous direct memory access virtual address space is created; When data is stored, the multimodal data is stored in the direct memory access virtual address space through the input / output memory management unit; When data access is performed, the multimodal data is read from the direct memory access virtual address space through the direct memory access control unit.

10. A large language model security test data processing system, characterized in that, include: The data acquisition module is used to acquire test data from the large language model security testing platform. The test data includes multimodal data, structured attack payload data, long-term session state data, and short-term temporary data. The region partitioning module is used to partition the main memory space into regions based on the test data to obtain multiple initial functional regions. The initial functional regions include multimodal regions, structured attack payload regions, long-term session state regions, or short-term temporary regions. A memory allocation module is used to build a corresponding regional memory management unit in each initial functional area. The regional memory management unit is used to allocate memory according to a memory allocation strategy. The data allocation module is used to allocate the test data to the corresponding initial functional area after memory allocation for test data processing.

Citation Information

Patent Citations

  • Self-adaptive partition circulating storage method and device suitable for flash memory

    CN119473930A