Method and system for network attack defense based on large model

By introducing attack feature attention branches and multi-task pre-training into the Transformer architecture, the accuracy and real-time performance of network attack identification are improved, solving the problems of insufficient identification capabilities and long response cycles in existing technologies, and realizing automated network attack defense.

CN123184869APending Publication Date: 2026-11-27XIDIAN UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610683870.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-29
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing network attack defense technologies cannot effectively identify unknown and variant attacks, have high false positive and false negative rates, high inference latency, lack real-time defense capabilities, and have poor compatibility between defense strategy generation and existing security devices, resulting in long response cycles and difficulty in dealing with rapidly spreading network attacks.

Method used

It adopts a network security model based on the Transformer architecture, sets an attack feature attention branch in each layer, improves the attack feature recognition capability through an attack feature weight correction mechanism, and combines multi-task pre-training and fine-tuning to achieve real-time attack detection and defense strategy generation, while being compatible with existing network security devices.

Benefits of technology

It achieves high-precision identification of unknown attacks, reduces false positive and false negative rates, meets real-time defense requirements, reduces inference latency, and achieves automated defense from attack discovery to policy generation without large-scale modification of the existing network architecture.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123184869A_ABST
    Figure CN123184869A_ABST
Patent Text Reader

Abstract

The application discloses a network attack defense method and system based on a large model, and belongs to the technical field of network security. The method constructs a sample data set based on network full-dimension security data; a network security model based on a Transform architecture is constructed, an attack feature attention branch parallel to a main multi-head attention layer is additionally arranged in each Transform block, the branch gives a higher attention weight to a pre-bound attack identification token through a weight correction mechanism, and a trained model is obtained after multi-task pre-training and fine-tuning; real-time data is input into the trained model, and binary classification detection, attack type identification, cross-session attack path correlation tracing and attack situation assessment are sequentially completed to obtain full-dimension attack situation identification results; and based on the results, a defense strategy covering only attack sources, attack paths and affected assets is generated according to the principle of least privilege in combination with network topology and asset importance levels. Through a double-track parallel model architecture and full-link closed-loop design, the application takes into account the detection real-time performance and identification accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer network security technology, specifically to a network attack defense method and system based on a large model. Background Technology

[0002] With the continuous iteration of cyberattack methods, complex attacks such as variant malicious code, zero-day vulnerability exploitation, APT targeted attacks, and DDoS variant attacks are occurring frequently. Existing cyberattack defense technologies are facing severe challenges and cannot meet the core needs of current cybersecurity protection.

[0003] In existing technologies, the application of general-purpose large models in network attack detection is still mainly focused on single classification tasks. Model pre-training does not fully consider the attack semantics and evolutionary patterns in the cybersecurity field, resulting in weak generalization ability to identify unknown and variant attacks, and high false positive and false negative rates. Furthermore, conventional Transformer architectures require full-sequence semantic encoding during inference, leading to high inference latency and difficulty in meeting the low-latency requirements of real-time defense. Moreover, the model's attention mechanism lacks focus on attack features, and attack behavior features in long sequences are easily overwhelmed by normal business data, affecting detection performance. In addition, existing detection and response processes are mostly serially separated architectures, lacking automated linkage between detection capabilities and defense execution. Defense strategies largely rely on manual formulation, making rapid closed-loop processing difficult.

[0004] In terms of defense strategy generation, existing methods generally adopt generic blocking rules, lacking detailed consideration of attack scope, asset importance, and business continuity, which can easily cause disruption to normal business operations. Furthermore, the policy generation suffers from poor compatibility with existing security devices; rule formats, syntax, and execution logic are difficult to adapt automatically, still requiring significant manual intervention. This results in a long response cycle from attack detection to policy implementation, making it difficult to cope with rapidly spreading cyberattacks. These problems severely restrict further improvements in network security protection capabilities, urgently requiring an integrated network attack defense solution capable of real-time detection, accurate identification, automatic response, and continuous optimization.

[0005] In terms of defense strategy generation, existing methods generally adopt generic blocking rules, lacking detailed consideration of attack scope, asset importance, and business continuity, which can easily cause disruption to normal business operations. Furthermore, the policy generation suffers from poor compatibility with existing security devices; rule formats, syntax, and execution logic are difficult to adapt automatically, still requiring significant manual intervention. This results in a long response cycle from attack detection to policy implementation, making it difficult to cope with rapidly spreading cyberattacks. These problems severely restrict further improvements in network security protection capabilities, urgently requiring an integrated network attack defense solution capable of real-time detection, accurate identification, automatic response, and continuous optimization. Summary of the Invention

[0006] To address the problems existing in the prior art, this invention provides a network attack defense method and system based on a large model. The large model is deeply integrated into the entire attack defense chain, which greatly improves the accuracy of unknown attack identification, reduces the false positive and false negative rates, meets the real-time defense requirements, is compatible with existing network security equipment, and does not require large-scale modification of the existing network architecture.

[0007] This invention is achieved through the following technical solution: A network attack defense method based on a large model includes the following steps: A sample dataset with a standardized token sequence format was constructed based on comprehensive network security data. A network security model based on the Transformer architecture is constructed. Each Transformer block of the network security model is configured with an attack feature attention branch that is connected in parallel with the backbone multi-head attention layer. The attack feature attention branch assigns a higher attention weight to the pre-bound network attack identifier token than that of the normal business token through an attack feature weight correction mechanism. The network security model is pre-trained using a multi-task pre-training method, and then fine-tuned to obtain the trained network security model. The pre-processed data is input into the trained network security model. The attack feature attention branch is used to extract attack features from the input data. The extracted attack features are subjected to binary classification detection. The data that is detected as abnormal is identified as an attack type. The identified attack data is traced across the session attack path. The attack intent and harm level are assessed based on the traceability results to obtain a full-dimensional attack situation identification result. Based on the comprehensive attack situation identification results, combined with the network topology and asset importance level, the network security model executes the principle of least privilege to generate a defense strategy that only covers the attack source, attack path and affected assets.

[0008] Preferably, the sample dataset for constructing the standardized token sequence format includes: Data cleaning is performed on the collected network security data from all dimensions to remove duplicate and invalid data; The cleaned data is transformed into a structured serialization, and the structured text is converted into a token sequence by a byte-pair encoding word segmenter with built-in network attack identifier tokens; The token sequence is normalized and either padded or truncated to a fixed length. For long session sequences exceeding the fixed length, the portion of the token sequence containing the network attack identifier token is retained first. Data augmentation is performed on the normalized data to increase the number of samples of niche attack types, resulting in a sample dataset in the standardized token sequence format.

[0009] Preferably, the attack feature weight correction mechanism includes: An attack feature weight coefficient matrix is ​​pre-generated, wherein the weight coefficient corresponding to the token position that matches the network attack identifier token in the attack feature weight coefficient matrix is ​​greater than the weight coefficient corresponding to the normal business token position. The modified attention weights are obtained by multiplying the basic attention weights by the attack feature weight coefficient matrix and then adding the modified attention weights back to the basic attention weights.

[0010] Preferably, the multi-task pre-training method includes at least two of the following: masked language model task, attack sequence temporal prediction task, attack and normal sample comparison learning task, and attack and defense strategy matching task.

[0011] Preferably, the cross-session attack path association and tracing includes: Based on the context window of the network security model and the attention branch of the attack features, log data across time periods, sessions, and devices are correlated to reconstruct the entire attack chain from initial access, command execution, persistent residence, privilege escalation, lateral movement, data collection to data leakage.

[0012] Preferably, the generation of defense strategies that only cover the attack source, attack path, and affected assets includes: Based on the comprehensive attack situation identification results, the attack source address and port range, the protocols and vulnerabilities exploited by the attack, and the range of affected assets are determined. Differentiated protection priorities are set according to the importance level of assets. Emergency strategies are generated for Tier 1 core assets with the priority of blocking the attack chain. Protection strategies including interception and alarm are generated for Tier 2 important assets. Control strategies including early warning and endpoint detection are generated for Tier 3 ordinary assets.

[0013] Preferably, after generating the defense strategy that only covers the attack source, attack path, and affected assets, it further includes: The defense strategy is subjected to rule conflict verification and business impact pre-verification. After the verification is passed, it is sent to the corresponding network security device for execution. The rule conflict check is used to check whether the defense strategy conflicts with existing rules. The business impact pre-verification is used to predict whether the impact of the defense strategy on normal business exceeds a preset threshold.

[0014] Preferably, the process of obtaining the trained cybersecurity model through fine-tuning includes: Freeze the backbone network parameters of the network security model, and fine-tune only the query matrix, key matrix and linear layer of the model output layer of the attack feature attention branch by performing low-rank decomposition; The fine-tuning includes a supervised fine-tuning phase using strongly labeled data, a scenario-based migration fine-tuning phase using dedicated business data, and a reinforcement learning fine-tuning phase based on feedback from cybersecurity experts.

[0015] A network attack defense system based on a large model includes: The data preprocessing module is used to construct a sample dataset in a standardized token sequence format based on network security data from all dimensions. The model building and training module is used to build a network security model based on the Transformer architecture. Each Transformer block of the network security model is set with an attack feature attention branch that is connected in parallel with the backbone multi-head attention layer. The attack feature attention branch assigns a higher attention weight to the pre-bound network attack identifier token than the normal business token through an attack feature weight correction mechanism. The network security model is pre-trained using a multi-task pre-training method, and then fine-tuned to obtain the trained network security model. The attack detection and situation awareness module is used to input the real-time preprocessed data into the trained network security model, extract attack features from the input data through the attack feature attention branch, perform binary classification detection on the extracted attack features, identify the attack type of the data detected as abnormal, perform cross-session attack path association and source tracing on the identified attack data, and evaluate the attack intent and harm level based on the source tracing results to obtain the full-dimensional attack situation identification results. The defense strategy generation module is used to generate a defense strategy that only covers the attack source, attack path and affected assets based on the full-dimensional attack situation identification results, combined with the network topology and asset importance level, and by executing the principle of least privilege through the network security model.

[0016] An electronic device includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the large-model-based network attack defense method.

[0017] Compared with the prior art, the present invention has the following beneficial technical effects: This application proposes a network attack defense method based on a large model. At the model architecture level, each Transformer block adds an attack feature attention branch parallel to the backbone multi-head attention layer. An attack feature weight correction mechanism assigns higher attention weights to pre-bound network attack identifier tokens than normal business tokens, forming a differentiated processing mechanism where the backbone learns global semantics and the branches focus on attack features. This allows for focused extraction of attack features without requiring full sequence encoding. At the attack detection level, real-time data is input into the trained network security model, sequentially performing binary classification detection, attack type identification, cross-session attack path association and tracing, and attack posture assessment. Cross-session tracing uses the model's long context window to associate multi-dimensional data across time and space, reconstructing the entire attack chain. At the defense strategy level, based on the attack posture identification results, combined with network topology and asset importance levels, a defense strategy covering only the attack source, attack path, and affected assets is generated according to the principle of least privilege. This method, through innovative model architecture and a closed-loop design across the entire chain, balances real-time detection with identification accuracy, achieving automated defense from attack discovery to strategy generation.

[0018] This application also proposes a network attack defense system based on a large model, an electronic device, and a computer storage medium, which possess all the advantages of the aforementioned network attack defense methods based on large models. Attached Figure Description

[0019] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a flowchart of the network attack defense method based on a large model according to the present invention; Figure 2 This is an architecture diagram of the network attack defense system based on a large model according to the present invention; Figure 3 This is a schematic diagram of the internal architecture of the Transformer block for the attack feature attention branch of the present invention. Figure 4 This is a flowchart of the attention weight calculation for the attack feature attention branch of the present invention; Figure 5 This is a flowchart of the multi-task pre-training method of the present invention. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0022] Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0023] like Figure 1-5 As shown, a network attack defense method based on a large model includes the following steps: Step 1: Obtain network security data from multiple sources using a heterogeneous data acquisition method. Perform data cleaning, structured serialization conversion, and data normalization preprocessing operations on the security data in sequence to obtain a sample dataset in a standardized token sequence format.

[0024] S11: Collect network security data from all dimensions, including at least one of network traffic data, multi-source device log data, external threat intelligence, and sample data.

[0025] Specifically, the network traffic data is collected by using the mirror port of the core switch to collect all north-south and east-west network traffic, covering all protocol types such as Transmission Control Protocol / Internet Protocol, Hypertext Transfer Protocol / Hypertext Transfer Security Protocol, Domain Name System Protocol, File Transfer Protocol, Secure Shell Protocol, and Remote Desktop Protocol, and completely capturing the packet header, payload, and session timing information of the data packets.

[0026] The method for collecting multi-source device log data is as follows: through standardized protocols such as system log protocol and representational state transition application programming interface, it connects with the enterprise's existing full range of security devices and business systems to collect firewall session logs, web application firewall alarm logs, intrusion detection and prevention system attack logs, endpoint detection and response system endpoint behavior logs, web application access logs, server system logs, database audit logs, and virtual private network access logs.

[0027] The external threat intelligence and sample data are collected by simultaneously connecting to general vulnerability disclosure / national information security vulnerability databases, ATT&CK attack frameworks, open-source threat intelligence platforms, national-level attack and defense exercise historical sample databases, and enterprise historical attack and defense confrontation sample data, providing full-domain data support for model training.

[0028] In some embodiments, the collection of the aforementioned comprehensive network security data can also be achieved using dedicated hardware devices such as deep packet inspection equipment, network traffic splitters, and traffic probes, or by batch importing historical log data through protocols such as file transfer protocols and secure file transfer protocols. The external threat intelligence can also be integrated with data sources such as commercial threat intelligence platforms and industry-shared threat intelligence alliances.

[0029] S12: Perform data cleaning on the collected network security data in sequence to remove noisy data such as duplicate logs, invalid empty data packets, garbled sessions, incomplete sessions, and meaningless heartbeat packets; and based on the normal business baseline of the enterprise, filter high-frequency redundant normal business access data, and retain only valid sessions, abnormal behavior logs and records related to full attack.

[0030] S13: The cleaned unstructured logs and semi-structured traffic data are converted into structured text in a unified format. The unified template includes: timestamp, source internet protocol address and port, destination internet protocol address and port, protocol type, event content, asset information, and alarm level. Then, a byte-pair encoding segmenter optimized for network security scenarios is used to convert the structured text into a token sequence. The byte-pair encoding segmenter has built-in six special tokens specific to network attacks, including special tokens for structured query language injection attacks, cross-site scripting attacks, distributed denial-of-service attacks, web page backdoor attacks, malware remote control communication, and zero-day vulnerability exploitation attacks. These tokens are used to accurately identify attack-related semantics.

[0031] S14: Convert numerical data such as Internet Protocol address, port number, timestamp, and request frequency into a unified encoding format, and at the same time, complete or truncate the token sequence to a fixed length of 16k to adapt to the 16k context window input requirements of the network security dedicated large model; for long session sequences exceeding 16k, prioritize the retention of feature fragments and key temporal nodes that match special attack tokens to ensure that the core attack features are not lost.

[0032] S15: For niche attacks, novel zero-day attacks, and advanced persistent threat attack samples with insufficient sample size, at least one data augmentation method among adversarial sample generation, back-translation augmentation, random mask replacement, and synthetic minority class oversampling techniques is used to generate new samples that conform to the essential characteristics of the attack, thereby expanding the sample size of niche attacks to more than 10 times the original number, and obtaining a sample dataset.

[0033] In some embodiments, the data augmentation method may also employ deep learning methods such as generative adversarial networks to generate attack samples, variational autoencoder-based sample generation, and diffusion model-based attack traffic generation.

[0034] S16: Divide the preprocessed full dataset into a pre-training dataset, a fine-tuning dataset, and a test dataset according to a preset ratio. The pre-training dataset contains weakly labeled or unlabeled full-scale cybersecurity domain samples for learning the model's basic semantics and attack logic. The fine-tuning dataset contains strongly labeled information on attack types, attack levels, attack intentions, and optimal defense strategies for optimizing the model's scenario-based capabilities. The test dataset contains labeled samples, with unknown attack samples accounting for no less than 30%, for comprehensive verification of the model's performance.

[0035] By employing a comprehensive data collection model, this approach achieves complete coverage of the entire attack chain, unlike existing solutions that rely on fragmented collection methods such as collecting only single alarm logs or traffic data. Its preprocessing workflow addresses the issues of single data sources, lack of domain-specific adaptation, and imbalanced sample distribution found in existing solutions. A built-in byte-pair encoding segmenter with a special token specific to network attacks accurately identifies attack-related semantics, avoiding incorrect segmentation of attack payloads by general-purpose segmenters and significantly improving the quality and feature matching accuracy of the model's input data.

[0036] Step 2: Construct a network security model based on the Transformer architecture. Each Transformer block of the model is configured with an attack feature attention branch that is connected in parallel with the backbone multi-head attention layer. The attack feature attention branch is configured with an attack feature attention head and pre-bound with the embedding vector of the network attack identifier token. The model is pre-trained using a four-task combination multi-task pre-training method in the field of network security, and then optimized through scenario-based fine-tuning to obtain the network security model, which is used for real-time attack detection, situational awareness and defense strategy generation.

[0037] S21: Construct a cybersecurity model with an Attention Branch for Attack Characteristics based on the Transformer architecture. The network security model in this embodiment adopts a decoder-only Transformer architecture with a total of 40 Transformer blocks, a backbone multi-head attention layer with 64 attention heads, a hidden layer dimension of 4096, and a context window size of 16k. Each Transformer block of the model has an attack feature attention branch that is connected in parallel with the backbone multi-head attention layer.

[0038] The input to the attack feature attention branch and the input to the backbone multi-head attention layer are homologous token embedding sequences. The attention output of the attack feature attention branch and the output of the backbone multi-head attention layer are concatenated and then fed into the layer normalization layer and the feedforward neural network layer. The attack feature attention branch has 32 built-in attack feature attention heads, which is half the total number of heads in the backbone multi-head attention layer. This forms a dual-track parallel processing architecture of "the backbone learns global semantics, and the branches focus on attack features". Attack features can be extracted without completing full sequence encoding, which significantly reduces inference latency.

[0039] See Figure 4 The attention weight calculation rule for the attack feature attention branch is as follows: attention is focused on attack-related tokens through the attack feature weight correction mechanism. First, calculate the basic attention weights, inputting the token embedding sequence. ; in, n The length of the token sequence. d For the embedding dimension, the query matrix Q, key matrix K, and value matrix V are obtained through linear transformation. The basic attention weights are calculated as follows:

[0040] in, Let be the dimension of the key matrix; Then, the attack feature weights are corrected by pre-generating the attack feature weight coefficient matrix. In the matrix, the token positions that match the six pre-bound network attack identifier tokens are assigned a weight coefficient of 3.0, while the weight coefficients for the remaining normal business token positions are set to 0.2. The final adjusted attention weights are as follows:

[0041] Finally, calculate the attention output. This serves as the final output of the attack feature attention branch.

[0042] The pre-binding implementation of the network attack identifier tokens is as follows: six network attack identifier tokens correspond to the semantic features of a core type of attack, specifically: the Structured Query Language Injection Attack identifier token corresponds to Structured Query Language Injection Attack, the Cross-Site Scripting Attack identifier token corresponds to Cross-Site Scripting Attack, the Distributed Denial-of-Service Attack identifier token corresponds to Denial-of-Service Attack, the Webpage Backdoor Attack identifier token corresponds to Webpage Backdoor Attack, the Malware Remote Control Communication identifier token corresponds to Malware Remote Control Communication, and the 0-day Vulnerability Exploitation Attack identifier token corresponds to 0-day Vulnerability Exploitation Attack; each network attack identifier token completes the learning of a fixed embedding vector during the pre-training stage and is pre-bound to the attack feature attention branch, ensuring that the model can quickly identify attack-related semantics during the encoding stage and achieve priority focus on attack features.

[0043] In some embodiments, the network security model may also employ an encoder-decoder Transformer architecture or be extended using a hybrid expert architecture.

[0044] In some embodiments, the number of attack feature attention heads in the attack feature attention branch can be adjusted to be between one-quarter and one-half of the total number of heads in the main multi-head attention layer.

[0045] In some embodiments, in the attack feature weight coefficient matrix, the token position weight coefficient matching the network attack identifier token can be set to any value in the range of 2.0 to 5.0, and the weight coefficients of the other normal business token positions can be set to any value in the range of 0.1 to 0.5.

[0046] In some embodiments, the types and number of network attack identification tokens can be expanded according to actual protection needs, such as adding file inclusion attack identification tokens, deserialization attack identification tokens, server request forgery attack identification tokens, etc.

[0047] S22: The network security model is pre-trained using a four-task combination multi-task pre-training framework from the field of network security.

[0048] The pre-trained dataset contains a total of 12TB of data, including more than 2.5 million labeled attack samples and more than 6 million normal traffic samples, covering all types of network attack scenarios, all protocol types, and all attack stages.

[0049] See Figure 5 The four parallel pre-training tasks specifically include: 1) Task 1 is a masked language modeling task. It involves randomly masking 15% of tokens, predicting the masked tokens, and learning the basic semantic features of network security data. The loss function is cross-entropy loss. .

[0050] For example, the key feature token in the masked SQL injection payload allows the model to learn the semantic rules of injection attacks, which is different from the existing general-purpose models that only learn natural language semantics and cannot adapt to professional network security scenarios.

[0051] 2) Task 2 is an attack sequence temporal prediction task. Given the first 80% of tokens in the attack sequence, predict the subsequent 20% of attack behavior tokens, learning the temporal evolution of multi-stage attacks. The loss function is cross-entropy loss. .

[0052] For example, by inputting the initial access and execution sequence of an APT attack, the model can predict subsequent attack behaviors such as lateral movement, privilege escalation, and data theft, thereby enabling the prediction of attack trends and solving the problem that existing solutions can only detect attacks after they occur and cannot provide early warnings.

[0053] 3) Task 3 is an attack-normal sample contrast learning task. It adopts an intra-batch contrast learning mode to narrow the feature distance between samples of the same type and widen the feature distance between samples of different types, so as to learn the essential boundary between normal traffic and attack traffic. The loss function is the information-noise contrast estimation loss. .

[0054] For example, by narrowing the feature vector distance between SQL injection samples of the same type and widening the feature distance between SQL injection samples and normal web access samples, the model can grasp the essential difference between attacks and normal behavior, rather than just memorizing surface rules, thus greatly improving the ability to identify unknown variant attacks.

[0055] 4) Task 4 is an attack-defense strategy matching task. Given an attack sample, predict the corresponding optimal defense strategy token sequence, learn the mapping relationship between attack behavior and defense strategy, and use cross-entropy loss as the loss function. .

[0056] For example, by inputting ransomware attack samples, the model can predict the optimal defense strategies such as terminal isolation, C2 communication blocking, and data backup. This allows the model to master the defense logic during the pre-training stage, laying the foundation for subsequent strategy generation. This approach differs from existing solutions that separate detection and defense capabilities.

[0057] The total loss function is a weighted sum of the losses from the four tasks:

[0058] The optimal training hyperparameters are: learning rate 3e-5, batch size 64, training iterations 200,000, context window length 16k, AdamW optimizer, weight decay 0.01, warm-up steps 2000, mixed precision 16-bit floating-point training, and pre-training completed on 16 A800 graphics processors.

[0059] In some embodiments, the loss weights of the four tasks can be adjusted to other ratios according to the actual scenario, such as an equal ratio of 0.25:0.25:0.25:0.25, or a ratio of 0.4:0.2:0.2:0.2 with a focus on the masking language model task. The pre-training can also include other cybersecurity tasks, such as attack payload reconstruction, attack tool identification, and vulnerability number classification. The graphics processor can also be other types of graphics processors or dedicated AI acceleration chips.

[0060] S23: A low-rank adaptation fine-tuning method is adopted, freezing 100% of the parameters of the model's backbone network and only fine-tuning the query matrix, key matrix, and linear layers of the model's output layer in the attack feature attention branch using low-rank decomposition. Fine-tuning is divided into three stages: The first stage is supervised fine-tuning, using a strongly labeled fine-tuning dataset to fine-tune four core tasks: attack binary classification detection, fine-grained attack type identification, attack intent and harm level assessment, and defense strategy generation; the second stage is scenario-based transfer fine-tuning, using the company's specific business data, normal business baseline, and historical attack samples for transfer learning to adapt to the traffic characteristics and protection needs of the company's specific business scenarios; the third stage is reinforcement learning fine-tuning based on human feedback, inviting cybersecurity experts to score and rank the attack identification results, attack path tracing conclusions, and defense strategies generated by the model, and then optimizing based on human feedback through reinforcement learning.

[0061] For example, the optimal hyperparameters are: rank 8, scaling factor 16, random kill rate 0.05, learning rate 2e-6, batch size 32, training iterations 20,000, and the optimizer is AdamW.

[0062] In some embodiments, the scenario-based fine-tuning can also employ other parameter-efficient fine-tuning methods such as full-parameter fine-tuning, adapter fine-tuning, and prefix fine-tuning. The rank of the low-rank adaptation fine-tuning can be set to other values ​​within the range of 4 to 16. The reinforcement learning fine-tuning based on human feedback can also employ alternative methods such as direct preference optimization.

[0063] By constructing a dual-track parallel Transformer architecture with attack feature attention branches, a differentiated processing mechanism is achieved where the backbone learns global semantics and the branches focus on attack features. An attack feature weight correction mechanism amplifies the attention weights of attack-related tokens by more than 3 times, while suppressing ineffective attention occupation by normal business tokens, improving the efficiency of attack feature extraction by more than 5 times. The effective utilization rate of long context windows increases from less than 20% to over 90%. A four-task combined multi-task pre-training framework allows the model to comprehensively learn four core capabilities during the pre-training stage: attack semantics, temporal patterns, classification boundaries, and defense mapping. Low-rank adaptation fine-tuning allows for rapid scenario adaptation while preserving the model's basic generalization capabilities.

[0064] Step 3: Input the preprocessed data into the network security model in real time, and complete the focused extraction of attack features through the attack feature attention branch. Then, complete the normal or abnormal binary classification detection, fine-grained attack type identification, cross-session attack path association and source tracing, attack intent and hazard level assessment in sequence to obtain the complete attack situation identification result. The complete attack situation identification result is used to generate defense strategy.

[0065] S31: Real-time network traffic is accessed to the system in real time through mirror ports and device logs through the system log protocol or the expressive state transition application interface. After real-time data cleaning, structured serialization conversion and data normalization are completed by the preprocessing module, the data is input into the network security model for real-time inference.

[0066] The single data inference adopts a streaming encoding mode. The attack feature attention branch completes the attack feature extraction synchronously during the encoding stage, without waiting for the full sequence encoding to be completed. The average inference latency of a single data is reduced to 7.2ms, which meets the real-time requirement of less than 10ms for network defense.

[0067] S32: The network security model first classifies the input data into normal or abnormal categories and outputs the abnormal confidence level. When the abnormal confidence level exceeds a preset threshold of 90%, it is determined to be abnormal data and enters the second-level fine-grained identification stage. Normal data with an abnormal confidence level below the threshold is directly marked as normal traffic and no further processing is required.

[0068] In some embodiments, the preset threshold for the anomaly confidence level can be adjusted to a value in the range of 80% to 95% based on the security strategy of the actual protection scenario.

[0069] S33: The network security model outputs attack data for data deemed abnormal, including attack type, attack subtype, exploited vulnerability number, and corresponding ATT&CK attack techniques and tactical phase.

[0070] The attack types include Structured Query Language injection attacks, Cross-Site Scripting attacks, Distributed Denial-of-Service attacks, Webpage backdoor attacks, Malware attacks, Advanced Persistent Threat attacks, Phishing attacks, etc., and support the identification of more than 200 attack types.

[0071] S34: Based on the attack identification results, according to the same attack chain or the same attacker characteristics, the multi-dimensional data across time and space is correlated through a 16k long context window and the attack feature attention branch to completely reconstruct the attack path and thus obtain the attack correlation elements. The multidimensional data spanning time and space refers to log data that spans time periods, sessions, and devices. The attack path includes the entire attack chain from initial access, command execution, persistent residence, privilege escalation, lateral movement, data collection to data leakage; The attack-related elements include the attack source Internet Protocol address, the attack springboard device, the infected terminal or server, the target asset, and the completed attack phase.

[0072] Reconstructing the entire attack chain means fully reconstructing the entire attack chain from initial access, command execution, persistent persistence, privilege escalation, lateral movement, data collection to data leakage.

[0073] In some embodiments, the cross-session associated time window can be extended to 14 days or 30 days as needed, by increasing the context window length or introducing an external memory module.

[0074] S35: The cybersecurity model assesses attack intent and severity based on attack type, attack path, completed attack phases, and the importance level of the target asset in the attack association elements, and obtains a full-dimensional attack situation identification result. The attack intents include data theft, ransomware encryption, system sabotage, and internal network penetration; The hazard levels are divided into four levels: extremely high, high, medium, and low. The full-dimensional attack situation identification results include attack type, attack source, attack path, affected assets, attack intent, hazard level, and corresponding ATT&CK technical number.

[0075] The cybersecurity model assesses attack intent and severity based on attack type, attack path, attack progress, and the importance level of the target asset. The final output is a full-dimensional attack situation identification result that includes attack type, attack source, attack path, affected assets, attack intent, severity level, and corresponding ATT&CK technical ID.

[0076] A four-layer detection model is adopted to automate the entire process from anomaly detection to accurate assessment. The first layer, binary screening of normal or anomaly data, reduces the computational cost of the model, and normal data requires no further processing. The second layer, fine-grained attack type identification, can locate vulnerabilities and attack techniques, providing a basis for the generation of subsequent defense strategies. The third layer, cross-session attack correlation and full-chain tracing, can completely reconstruct the attack chain, solving the problem of only being able to identify single-stage attack behavior and not being able to block it in advance. The fourth layer, attack intent and harm level assessment, provides decision support for differentiated defense responses.

[0077] Step 4: Based on the full-dimensional attack situation identification results, combined with the network topology, asset importance level and existing security device rule sets, the minimum scope defense strategy is generated through the least privilege principle defense strategy generation mechanism of the network security model. After rule conflict verification and business impact pre-verification, it is sent to the corresponding network security device for automatic execution.

[0078] The minimum-scope defense strategy is a defense strategy that only covers the attack source, attack path, and affected assets in the full-dimensional attack situation identification results.

[0079] The execution process of step 4 will be explained in detail below.

[0080] S41: Based on the attack posture identification results, define the range of Internet protocol addresses and ports of the attack source, the protocols and vulnerabilities exploited by the attack, the malicious behaviors executed by the attack, and the scope of affected assets; simultaneously, synchronize the enterprise asset ledger, clarify the importance level of affected assets, and classify them into Level 1 core assets, Level 2 important assets, and Level 3 ordinary assets. Level 1 core assets include core databases, business system servers, etc.; Level 2 important assets include office automation systems, financial systems, etc.; Level 3 ordinary assets include employee office terminals, etc.

[0081] S42: Set differentiated protection priorities based on asset importance level: For Tier 1 core assets, generate emergency strategies with priority on blocking attack chains and providing full-dimensional protection; for Tier 2 important assets, generate protection strategies that include interception, alerting, and investigation; for Tier 3 ordinary assets, generate control strategies that include early warning, endpoint detection and removal, and behavior monitoring.

[0082] S43: Combining the rule sets, supported rule syntax, and execution capabilities of existing security devices, generate minimal access control rules that only cover the attack source to the affected assets. The policy's scope only includes attack-related Internet protocol addresses, ports, protocols, and assets, without expanding the scope of blocking or interception.

[0083] For example, in response to an injection attack from a single source Internet Protocol address to port 8080 of a web server, only the web application firewall generates blocking rules for that source Internet Protocol address, that port, and that injection characteristic, as well as access control rules for the source Internet Protocol address to port 8080 of the web server. It does not block access to all ports from that source Internet Protocol address, nor does it shut down the entire web service.

[0084] Examples of defense strategies for typical attack scenarios are as follows: For distributed denial-of-service attacks: the perimeter firewall only blocks access to the attacked ports in the Internet Protocol address range of the attack source; the web application firewall enables attack protection for the corresponding ports and sets blocking rules based on access frequency and behavioral characteristics; the load balancer adjusts the traffic scrubbing threshold of the corresponding ports to divert attack traffic to the traffic scrubbing device.

[0085] For Structured Query Language (SCL) injection attacks: Add protection rules to the web application firewall targeting this injection feature; temporarily isolate unnecessary access channels between the attacked web server and the core database; push vulnerability remediation suggestions and trigger a full database backup; reset the database access account password and enable database abnormal access audit rules; add the source Internet Protocol address to the firewall's temporary blacklist.

[0086] For ransomware attacks: The endpoint detection and response system immediately isolates infected endpoints and disconnects them from the internal and external networks; the firewall and domain name system server block the Internet Protocol addresses and domain names corresponding to the ransomware's remote control communication; it triggers emergency backup tasks for core business systems and file servers; it issues ransomware signature detection and removal tasks to all endpoints on the internal network; and it pushes emergency alerts to security administrators and end users.

[0087] In some embodiments, the generation of the defense strategy can also incorporate a strategy template library, pre-setting strategy templates for common attack types, and generating the defense strategy through parameterized configuration. The asset importance level can also be divided into more levels, or dynamically adjusted based on business impact analysis.

[0088] S44: After the policy is generated, double verification is automatically performed. The implementation method for rule conflict verification is as follows: automatically obtain the existing rules of the existing security devices, and verify whether there are logical conflicts, priority conflicts, or address range conflicts between the generated defense policy and the existing rules; if conflicts exist, automatically adjust the policy's priority, scope of application, and execution order.

[0089] The implementation method for business impact pre-verification is as follows: simulate the changes in business traffic after policy execution using a network security model, and combine this with the enterprise's normal business baseline to predict the impact of policy execution on normal business; if the predicted impact exceeds a preset threshold of 0.1%, the system automatically regenerates the policy, narrows the interception scope, and adjusts the rule granularity until the business compatibility requirements are met.

[0090] In some embodiments, the preset threshold for pre-verification of business impact can be adjusted to a value within the range of 0.05% to 0.5% according to the enterprise's business continuity requirements. The rule conflict verification can also employ formal verification methods, automatically solving for the optimal execution order through a rule conflict detection algorithm.

[0091] S45: Defense policies that pass dual verification are automatically converted into rule syntax and format supported by the corresponding security devices through the device compatibility module. These rules are then distributed to the corresponding network security devices via a standardized application programming interface (API) and automatically execute defense operations. The system monitors the policy execution status in real time, confirming successful rule distribution and effectiveness, and simultaneously recording the entire policy execution process log. For attacks of extremely high severity, the system automatically triggers the emergency response process, immediately severing the connection between the attacked network segment and core assets. Simultaneously, alerts are pushed to security administrators via SMS, email, and enterprise instant messaging tools, and emergency response reports and attack attribution reports are automatically generated. Defense response time is reduced from minutes to 12ms.

[0092] The defense policy generation mechanism, based on the principle of least privilege, only covers the minimum scope of attack sources, attack paths, and affected assets for interception, without expanding the blocking scope. The impact of policy execution on normal business operations is reduced to 0.08%. A dual verification mechanism, including rule conflict checks and business impact pre-checks, prevents business interruption incidents from the outset. The device compatibility module automatically completes policy format conversion and distribution, achieving 100% compatibility with existing security devices' rules, and a 99.1% automatic execution success rate for defense policies.

[0093] Step 5: Collect feedback data on the execution effect of the defense strategy, fine-tune the dataset based on the feedback data, and perform periodic incremental fine-tuning of the network security model to obtain an updated network security model; the updated network security model is used to replace the original model to perform real-time attack detection and defense strategy generation, realizing closed-loop iterative optimization of defense capabilities.

[0094] S51: Continuously collect feedback data on the effectiveness of defense strategy execution, including: whether the attack was successfully blocked, whether the attack was reproduced, whether there were false alarms or missed alarms, newly discovered attack samples and new attack characteristics, security administrators' correction opinions on model output, optimization strategies for manual handling, and adversarial data from attack and defense drills.

[0095] S52: The collected feedback data is first manually reviewed by security experts to confirm the accuracy of the annotation information. Then, after standardization by the preprocessing module, it is added to the fine-tuning dataset, updating the dataset version. The dataset is version-managed, recording the content, new sample types, and number of samples for each update.

[0096] S53: The system performs periodic incremental fine-tuning of the network security model according to a preset cycle; in response to sudden new attacks or zero-day vulnerability attacks, emergency incremental fine-tuning is triggered. Incremental fine-tuning employs a low-rank adaptation fine-tuning method, optimizing only a small number of parameters in the attack feature attention branch and output layer. A single incremental fine-tuning can be completed within 30 minutes. For example, for a newly emerging zero-day vulnerability attack, after collecting 10 attack samples, incremental fine-tuning can be completed within 30 minutes, improving the identification accuracy of this vulnerability attack to over 95%.

[0097] In some embodiments, the periodic incremental fine-tuning period can be set to daily, weekly, or monthly. The incremental fine-tuning can also employ continuous learning methods such as elastic weight consolidation and progressive neural networks to reduce catastrophic forgetting.

[0098] S54: Performs full lifecycle management for each version of the cybersecurity model, recording the training dataset version, hyperparameter configuration, and performance verification metrics for each version. After each model update, performance verification is first completed in the test environment. Once verification is successful, a canary release strategy is adopted to gradually switch to the production environment, while retaining the previous stable version and supporting one-click rollback to ensure uninterrupted protection capabilities during model updates.

[0099] By collecting feedback data on the effectiveness of defense strategy execution and using low-rank adaptation for incremental fine-tuning, new attack characteristics can be learned within 30 minutes without manual updates to the rule base, whereas traditional rule engines require at least 72 hours to complete rule updates. Through model version management and canary release mechanisms, the stability of protection capabilities is ensured during model updates, avoiding increased false positive rates or business interruptions caused by model updates.

[0100] Correspondingly, this application also provides a network attack defense system based on a large model, including: The data preprocessing module is used to construct a sample dataset in a standardized token sequence format based on network security data from all dimensions. The model building and training module is used to build a network security model based on the Transformer architecture. Each Transformer block of the network security model is set with an attack feature attention branch that is connected in parallel with the backbone multi-head attention layer. The attack feature attention branch assigns a higher attention weight to the pre-bound network attack identifier token than the normal business token through an attack feature weight correction mechanism. The network security model is pre-trained using a multi-task pre-training method, and then fine-tuned to obtain the trained network security model. The attack detection and situation awareness module is used to input the real-time preprocessed data into the trained network security model, extract attack features from the input data through the attack feature attention branch, perform binary classification detection on the extracted attack features, identify the attack type of the data detected as abnormal, perform cross-session attack path association and source tracing on the identified attack data, and evaluate the attack intent and harm level based on the source tracing results to obtain the full-dimensional attack situation identification results. The defense strategy generation module is used to generate a defense strategy that only covers the attack source, attack path and affected assets based on the full-dimensional attack situation identification results, combined with the network topology and asset importance level, and by executing the principle of least privilege through the network security model.

[0101] The present invention has the following beneficial effects: First, in terms of inference efficiency and recognition accuracy, the dual-track parallel processing architecture consisting of the attack feature attention branch and the backbone multi-head attention layer allows the attack feature attention branch to complete the focused extraction of attack features synchronously during the encoding stage, without waiting for the entire sequence to be encoded. Under the premise of meeting the real-time requirements of network defense, it maintains a high attack recognition accuracy and solves the problem that the recognition accuracy drops significantly due to the reduction of latency by compressing the model parameters in existing solutions.

[0102] Secondly, regarding the generalization ability of unknown attacks, based on the four-task combination multi-task pre-training framework, the model learns the basic semantic features of network security data through the mask language model task, learns the temporal evolution law of multi-stage attacks through the attack sequence temporal prediction task, learns the classification boundary between normal traffic and attack traffic through the attack and normal sample comparison learning task, and learns the mapping relationship between attack behavior and defense strategy through the attack and defense strategy matching task. This enables the model to grasp the essential characteristics of attacks in the pre-training stage and has a strong ability to identify unknown attacks such as 0-day vulnerability attacks and variant malicious code. This solves the problem that traditional rule engines can only match known attack features and traditional machine learning solutions rely on the surface features of labeled samples, resulting in insufficient generalization ability.

[0103] Third, in terms of cross-session attack identification, based on the model's long context window and attack feature attention branch, the attention weight of attack-related tokens is enhanced and the attention weight of normal business tokens is suppressed through the attack feature weight correction mechanism. This makes it less likely that key attack-related features in long sequences will be overwhelmed by a large amount of normal business data. It can perform correlation analysis on log data across time periods, sessions, and devices, and completely restore the entire attack chain. This solves the problem that existing solutions can only identify a single attack stage and cannot restore the complete attack chain.

[0104] Fourth, in terms of defense strategy generation, defense strategies are generated based on the principle of least privilege, covering only the attack source, attack path and affected assets. After rule conflict verification and business impact pre-verification, the strategies are sent to the corresponding network security devices for execution. This reduces the impact on normal business while blocking attacks. It can also be directly integrated with existing security devices without large-scale modification of the existing network architecture, solving the problems of business interruption and high cost of manual adaptation and modification caused by the coarse granularity of existing solutions.

[0105] Fifth, in terms of adaptive iteration, by using the low-rank adaptation incremental fine-tuning method, only a small number of parameters of the attack feature attention branch are updated, which can complete the learning of new attack features in a short time without the need for manual updates to the rule base. This achieves synchronous adaptation between protection capabilities and attack iteration, and solves the problem of rule update lag caused by the need for security experts to manually analyze new attack samples, extract features, and update the rule base in traditional rule engines.

[0106] It should be noted that, in the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another device, or some features may be ignored or not executed. The modules described as separate components may or may not be physically separated. The components shown as modules may be one or more physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the modules can be selected to achieve the purpose of the solution in this embodiment according to actual needs.

[0107] Furthermore, in the various embodiments of the present invention, the modules can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The integrated unit described above can be implemented in hardware or as a software functional unit.

[0108] An electronic device provided in this application includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of the network attack defense method based on a large model as described in any of the above embodiments.

[0109] Another electronic device provided in this application embodiment may further include: an input port connected to a processor for transmitting multimodal data collected by an external acquisition device to the processor; a display unit connected to the processor for displaying the processor's processing results to the outside world; and a communication module connected to the processor for enabling communication between the electronic device and the outside world. The display unit may be a display panel, a laser scanning display, etc.; the communication method adopted by the communication module includes, but is not limited to, Mobile High Definition Link (HML), Universal Serial Bus (USB), High Definition Multimedia Interface (HDMI), and wireless connection (including Wi-Fi, Bluetooth, Bluetooth Low Energy, and IEEE 802.11s-based communication technology).

[0110] This application provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the steps of the network attack defense method based on a large model as described in any of the above embodiments.

[0111] For descriptions of relevant parts of the network attack defense system, electronic device, and computer-readable storage medium based on large models provided in this application, please refer to the detailed descriptions of the corresponding parts in the network attack defense method based on large models provided in this application, which will not be repeated here. Furthermore, parts of the technical solutions provided in this application that are consistent with the implementation principles of corresponding technical solutions in the prior art have not been described in detail to avoid excessive elaboration.

[0112] The above content is only for illustrating the technical concept of the present invention and should not be construed as limiting the scope of protection of the present invention. Any modifications made to the technical solution based on the technical concept proposed in this invention shall fall within the scope of protection of the claims of this invention.

Claims

1. A network attack defense method based on a large model, characterized in that, Includes the following steps: A sample dataset with a standardized token sequence format was constructed based on comprehensive network security data. A network security model based on the Transformer architecture is constructed. Each Transformer block of the network security model is configured with an attack feature attention branch that is connected in parallel with the backbone multi-head attention layer. The attack feature attention branch assigns a higher attention weight to the pre-bound network attack identifier token than the normal business token through an attack feature weight correction mechanism. The network security model is pre-trained using a multi-task pre-training method, and then fine-tuned to obtain the trained network security model. The pre-processed data is input into the trained network security model. The attack feature attention branch is used to extract attack features from the input data. The extracted attack features are subjected to binary classification detection. The data that is detected as abnormal is identified as an attack type. The identified attack data is traced across the session attack path. The attack intent and harm level are assessed based on the traceability results to obtain a full-dimensional attack situation identification result. Based on the comprehensive attack situation identification results, combined with the network topology and asset importance level, the network security model executes the principle of least privilege to generate a defense strategy that only covers the attack source, attack path and affected assets.

2. The network attack defense method based on a large model according to claim 1, characterized in that, The sample dataset for constructing the standardized token sequence format includes: Data cleaning is performed on the collected network security data from all dimensions to remove duplicate and invalid data; The cleaned data is transformed into a structured serialization, and the structured text is converted into a token sequence by a byte-pair encoding word segmenter with built-in network attack identifier tokens; The token sequence is normalized and either padded or truncated to a fixed length. For long session sequences exceeding the fixed length, the portion of the token sequence containing the network attack identifier token is retained first. Data augmentation is performed on the normalized data to increase the number of samples of niche attack types, resulting in a sample dataset in the standardized token sequence format.

3. The network attack defense method based on a large model according to claim 1, characterized in that, The attack feature weight correction mechanism includes: An attack feature weight coefficient matrix is ​​pre-generated, wherein the weight coefficient corresponding to the token position that matches the network attack identifier token in the attack feature weight coefficient matrix is ​​greater than the weight coefficient corresponding to the normal business token position. The modified attention weights are obtained by multiplying the basic attention weights by the attack feature weight coefficient matrix and then adding the modified attention weights back to the basic attention weights.

4. The network attack defense method based on a large model according to claim 1, characterized in that, The multi-task pre-training method includes at least two of the following: masked language model task, attack sequence temporal prediction task, attack and normal sample comparison learning task, and attack and defense strategy matching task.

5. The network attack defense method based on a large model according to claim 1, characterized in that, The cross-session attack path association and tracing includes: Based on the context window of the network security model and the attention branch of the attack features, log data across time periods, sessions, and devices are correlated to reconstruct the entire attack chain from initial access, command execution, persistent residence, privilege escalation, lateral movement, data collection to data leakage.

6. The network attack defense method based on a large model according to claim 1, characterized in that, The generated defense strategy only covers the attack source, attack path, and affected assets, including: Based on the comprehensive attack situation identification results, the attack source address and port range, the protocols and vulnerabilities exploited by the attack, and the range of affected assets are determined. Differentiated protection priorities are set according to the importance level of assets. Emergency strategies are generated for Tier 1 core assets with the priority of blocking the attack chain. Protection strategies including interception and alarm are generated for Tier 2 important assets. Control strategies including early warning and endpoint detection are generated for Tier 3 ordinary assets.

7. The network attack defense method based on a large model according to claim 1, characterized in that, After generating a defense strategy that only covers the attack source, attack path, and affected assets, it also includes: The defense strategy is subjected to rule conflict verification and business impact pre-verification. After the verification is passed, it is sent to the corresponding network security device for execution. The rule conflict check is used to check whether the defense strategy conflicts with existing rules. The business impact pre-verification is used to predict whether the impact of the defense strategy on normal business exceeds a preset threshold.

8. The network attack defense method based on a large model according to claim 1, characterized in that, The process of fine-tuning to obtain the trained cybersecurity model includes: Freeze the backbone network parameters of the network security model, and fine-tune only the query matrix, key matrix and linear layer of the model output layer of the attack feature attention branch by performing low-rank decomposition; The fine-tuning includes a supervised fine-tuning phase using strongly labeled data, a scenario-based migration fine-tuning phase using dedicated business data, and a reinforcement learning fine-tuning phase based on feedback from cybersecurity experts.

9. A system for implementing the network attack defense method based on a large model as described in any one of claims 1-8, characterized in that, include: The data preprocessing module is used to construct a sample dataset in a standardized token sequence format based on network security data from all dimensions. The model building and training module is used to build a network security model based on the Transformer architecture. Each Transformer block of the network security model is set with an attack feature attention branch that is connected in parallel with the backbone multi-head attention layer. The attack feature attention branch assigns a higher attention weight to the pre-bound network attack identifier token than the normal business token through an attack feature weight correction mechanism. The network security model is pre-trained using a multi-task pre-training method, and then fine-tuned to obtain the trained network security model. The attack detection and situation awareness module is used to input the real-time preprocessed data into the trained network security model, extract attack features from the input data through the attack feature attention branch, perform binary classification detection on the extracted attack features, identify the attack type of the data detected as abnormal, perform cross-session attack path association and source tracing on the identified attack data, and evaluate the attack intent and harm level based on the source tracing results to obtain the full-dimensional attack situation identification results. The defense strategy generation module is used to generate a defense strategy that only covers the attack source, attack path and affected assets based on the full-dimensional attack situation identification results, combined with the network topology and asset importance level, and by executing the principle of least privilege through the network security model.

10. An electronic device, characterized in that, It includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the network attack defense method based on a large model as described in any one of claims 1 to 8.