Paper deep dive
ExAI5G: A Logic-Based Explainable AI Framework for Intrusion Detection in 5G Networks
Saeid Sheikhi, Panos Kostakos, Lauri Loven
Intelligence
Status: succeeded | Model: Gemma-4-26B-A4B | Prompt: intel-v1 | Confidence: 98%
Last extracted: 6/21/2026, 10:24:31 AM
Summary
ExAI5G is a logic-based explainable AI (XAI) framework designed for intrusion detection in 5G networks. It integrates a Transformer-based deep learning model with Integrated Gradients for feature attribution and a surrogate decision tree for logical rule extraction. The framework leverages Large Language Models (LLMs) to convert these rules and attributions into human-readable, actionable natural language explanations. A novel three-part validation methodology is introduced to assess the semantic similarity, attribution faithfulness, and actionability of these explanations using an LLM-as-judge approach. The system demonstrates high performance (99.9% accuracy) and high rule fidelity (99.7%) on a 5G IoT intrusion dataset.
Entities (10)
Relation Signals (6)
Surrogate Decision Tree â derives â Logical Rules
confidence 100% ¡ extracts a surrogate decision tree to derive logical rules.
ExAI5G â evaluatedon â 5G IoT Intrusion Dataset
confidence 100% ¡ On a 5G IoT intrusion dataset, our system achieves 99.9% accuracy
Llama-3.3-70B â evaluates â LLM-generated explanations
confidence 100% ¡ use a separate, powerful evaluator LLM (llama3.3:70b) to assess actionability
ExAI5G â incorporates â Transformer-based IDS
confidence 100% ¡ integrating a Transformer-based deep learning IDS with logic-based explainable AI (XAI) techniques.
ExAI5G â uses â Integrated Gradients
confidence 100% ¡ The framework uses Integrated Gradients to attribute feature importance
ExAI5G â uses â Surrogate Decision Tree
confidence 100% ¡ extracts a surrogate decision tree to derive logical rules.
Cypher Suggestions (0)
No Cypher suggestions yet.
Abstract
Abstract:Intrusion detection systems (IDSs) for 5G networks must handle complex, high-volume traffic. Although opaque "black-box" models can achieve high accuracy, their lack of transparency hinders trust and effective operational response. We propose ExAI5G, a framework that prioritizes interpretability by integrating a Transformer-based deep learning IDS with logic-based explainable AI (XAI) techniques. The framework uses Integrated Gradients to attribute feature importance and extracts a surrogate decision tree to derive logical rules. We introduce a novel evaluation methodology for LLM-generated explanations, using a powerful evaluator LLM to assess actionability and measuring their semantic similarity and faithfulness. On a 5G IoT intrusion dataset, our system achieves 99.9\% accuracy and a 0.854 macro F1-score, demonstrating strong performance. More importantly, we extract 16 logical rules with 99.7\% fidelity, making the model's reasoning transparent. The evaluation demonstrates that modern LLMs can generate explanations that are both faithful and actionable, indicating that it is possible to build a trustworthy and effective IDS without compromising performance for the sake of marginal gains from an opaque model.
Tags
Links
- Source: https://arxiv.org/abs/2604.18052v1
- Canonical: https://arxiv.org/abs/2604.18052v1
Trouble viewing inline? Open PDF directly â
Full Text
52,308 characters extracted from source content.
Expand or collapse full text
ExAI5G: A Logic-Based Explainable AI Framework for Intrusion Detection in 5G Networks Saeid Sheikhi Panos Kostakos Lauri Loven Abstract Intrusion detection systems (IDSs) for 5G networks must handle complex, high-volume traffic. Although opaque âblack-boxâ models can achieve high accuracy, their lack of transparency hinders trust and effective operational response. We propose ExAI5G, a framework that prioritizes interpretability by integrating a Transformer-based deep learning IDS with logic-based explainable AI (XAI) techniques. The framework uses Integrated Gradients to attribute feature importance and extracts a surrogate decision tree to derive logical rules. We introduce a novel evaluation methodology for LLM-generated explanations, using a powerful evaluator LLM to assess actionability and measuring their semantic similarity and faithfulness. On a 5G IoT intrusion dataset, our system achieves 99.9% accuracy and a 0.854 macro F1-score, demonstrating strong performance. More importantly, we extract 16 logical rules with 99.7% fidelity, making the modelâs reasoning transparent. The evaluation demonstrates that modern LLMs can generate explanations that are both faithful and actionable, indicating that it is possible to build a trustworthy and effective IDS without compromising performance for the sake of marginal gains from an opaque model. keywords: Explainable AI (XAI), 5G Intrusion Detection, Large Language Models, Logic-Based Rule Extraction, Trustworthy AI â journal: Information Sciences [1]organization=Faculty of Information Technology and Electrical Engineering, University of Oulu, addressline=, city=Oulu, postcode=90570, state=, country=Finland 1 Introduction The rollout of 5G networks has enabled massive connectivity for IoT devices and critical services, but it also expands the attack surface for cyber intrusions [12, 5]. Machine learningâbased Intrusion Detection Systems (IDS) are being adopted to identify anomalous traffic [5, 13]. While deep learning models can achieve high detection rates, their decisions are often unclear, creating a trust gap for security operators[12, 10]. This raises an important question for security-critical domains: a slight improvement in performance metrics may not be worth the risk of an unexplainable system. Prior work has emphasized explainability in cybersecurity, for instance, by extracting decision rules or visualizing feature importance[16]. However, many XAI methods focus on feature-importance explanations (e.g., SHAP or LIME) that can be unstable and difficult to translate into actionable insights[16, 2]. There is a need for logic-based explanations, unambiguous rules defining the conditions under which an alert is triggered, to support expert reasoning and verification. In this paper, we introduce ExAI5G, an explainable AI framework that directly addresses the performance-vs-interpretability trade-off. The proposed approach first trains a Transformer-based IDS model, then makes it transparent by applying Integrated Gradients[17] to quantify feature importance and training a surrogate decision tree to extract human-readable logical rules. Finally, we leverage multiple LLMs to convert these rules and attributions into natural language and introduce a new methodology to quantitatively evaluate their quality, faithfulness, and actionability. The main contributions of the paper are as follows: 1. A novel XAI framework that makes a deep learning IDS transparent via logic rule extraction and validated natural language explanations. 2. A new three-part validation scheme to assess LLM-generated explanations, measuring semantic similarity, attribution faithfulness, and an expert-level actionability score. 3. A direct comparison with opaque, high-performing models, demonstrating that our explainable system achieves strong performance (99.9% accuracy) with a compact, high-fidelity (99.7%) rule set. 4. A quantitative analysis of explanations from four different LLMs, proving that modern models can achieve perfect scores in faithfulness and actionability. 5. A pilot expert study with two security analysts, comparing human ratings of explanation quality to the LLM-as-judge metrics and highlighting where they align and diverge. ExAI5G aims to enhance the transparency and reliability of AI-driven security systems by prioritizing trustworthiness alongside performance. The rest of the paper is organized as follows: Section 2 reviews related work; Section 3 presents our methodology; Section 4 outlines the experimental setup; Section 5 reports the results; Section 6 discusses our findings. Finally, Section 7 concludes the paper. 2 Related Work Intrusion Detection in 5G/IoT Networks. The security of 5G core and IoT networks has been the focus of extensive research, with various IDS solutions proposed to handle novel attack vectors and the scale of 5G traffic. Traditional signature-based methods struggle with new or evolving threats, leading to a surge in anomaly-based IDS using machine learning. For example, Fan et al. introduced IoTDefender, a federated transfer learning framework for 5G IoT intrusion detection that aggregates models from edge devices to improve detection of attacks across distributed data[5]. Sood et al. proposed an anomaly detection scheme for 5G networks using dimensionality reduction to preprocess features, improving classification efficiency for attacks such as unauthorized access and Denial of Service (DoS)[15]. In 5G contexts, Kim et al. focused on effective feature selection to identify Distributed Denial-of-Service (DDoS) attacks in a 5G core network environment, highlighting the importance of choosing discriminative features to handle high-volume IoT traffic[9]. These works demonstrate high detection rates but essentially treat the ML models as black boxes. As 5G IDS deployments become more complex (e.g., deep neural networks, federated learning), understanding model decisions becomes crucial for debugging and compliance. Explainable AI in Cybersecurity. Explainable AI has been utilized in security domains to build trust in automated decision-making processes. A recent survey by Charmet et al. reviews XAI techniques for cybersecurity, reporting that most approaches either visualize feature importances or provide example-based explanations (prototypes, counterfactuals) rather than logical reasoning[2]. They emphasize the need for explanations that security analysts can act on, aligning with Linkov et al.âs concept of moving âfrom explainable to actionableâ AI[10]. In intrusion detection, many studies employ post-hoc explanation methods such as Local Interpretable Model-agnostic Explanations (LIME) or Shapley Additive exPlanations (SHAP) to interpret deep learning models[11]. Gaspar et al. (2024) emphasize the challenges posed by LIME and SHAP in cybersecurity, indicating that the instability of feature importance ratings can hinder the trust and usability of these approaches for security practitioners. These methods can facilitate a better understanding of model decisions. However, their fluctuating outputs when applied to similar datasets raise doubts about their reliability [6]. More interpretable-by-design models like decision trees or rule-based classifiers have been revisited for IDS to offer transparency. Gyawali et al. integrated an explainability module into an IoT anomaly detection system, showing that highlighting feature importance (e.g., via heatmaps) helped administrators grasp why an alert was raised[8]. Similarly, Siganos et al. proposed an explainable AIâbased IDS for IoT, combining deep learning with an explanation interface to present the reasons for detections (such as particular network features being outside normal ranges)[14]. Our work builds on this literature by providing not just feature importance but also logical if-then rules that succinctly characterize attack traffic versus benign traffic, which can be more actionable (e.g., as firewall rules or forensic insights) than raw feature weights. Logic-Based Rule Extraction and Verification. Using logic to interpret ML models has a rich history. Early work by Craven & Shavlik introduced methods like TREPAN for extracting decision trees from trained neural networks, aiming to approximate the networkâs decisions with a set of logical conditions[4]. Similarly, rule extraction algorithms such as DeepRED (Zilke et al., 2016) decompose a deep neural network into equivalent rule sets[18]. These approaches ensure that each explanation (rule) corresponds to a region in feature space with a consistent predicted class, offering global insight into the model. In security, rule-based systems have long been used (e.g., Snort signatures), so being able to convert a learned IDS into rules helps in bridging data-driven models with expert systems. Recent studies have enhanced rule extraction with probabilistic reasoning; for instance, Contreras et al. combined logic rules with embedding analysis to explain deep models, producing rules that capture feature interactions in a comprehensible manner[3]. Logic-based explanations can also be formally verified or checked against domain knowledge (for example, verifying that a rule for detecting port scan attacks aligns with known indicator-of-compromise patterns). In our Framework, we use a surrogate decision tree (depth-limited) to extract rules that describe the IDS modelâs behavior. This not only provides an interpretable global model but also facilitates logic verification: we can examine if the extracted rules make sense (e.g., an IoT DoS attack rule might involve a high rate of MQTT messages) and whether any rules conflict or are redundant. Assessing the fidelity of the rule set to the original model ensures that the logical abstraction remains accurate. LLMs for Explainable AI. Large Language Models have recently been explored as tools for enhancing XAI by generating human-readable explanations from model data[1]. The conversational and reasoning abilities of LLMs (e.g., GPT-3.5, GPT-4) allow them to take structured information (like a set of rules or a feature attribution list) and produce a coherent narrative explanation[7]. A comprehensive survey by Bilal et al. discusses how LLMs can serve as intermediaries between complex model outputs and user-friendly explanations, highlighting use cases in which LLMs translate model decisions into domain language[1]. 3 Methodology The ExAI5G framework comprises four main stages: (1) a Transformer IDS model that learns to detect intrusions; (2) an Integrated Gradients (IG) attribution mechanism to evaluate feature importance; (3) a decision tree surrogate model to approximate the Transformerâs decision function, from which we extract logical rules; and (4) an LLM-mediated explanation module that generates and precisely validates natural language descriptions of the modelâs behavior. Figure 1 illustrates the framework at a conceptual level. Figure 1: ExAI5G Framework: a TabTransformer is trained on 5G network data; Integrated Gradients highlight important features; a surrogate decision tree produces rules; an LLM produces a high-level explanation. Data Splitting and Preprocessing: To prevent data leakage and ensure a robust evaluation, we first partition the raw training data into an 80% training set and a 20% validation set using stratified sampling. A StandardScaler is fitted only on the new, smaller training set. This same fitted scaler is then used to transform the training, validation, and test sets, ensuring that no information from the validation or test data influences the training process. Transformer IDS Model: We first transform all categorical and string-valued fields into numeric representations and then standardize the features. Our Transformer-like network projects each feature vector into a 128-dimensional embedding, appends a learnable [CLS] token, and processes this sequence through a Transformer encoder (6 layers, 8 heads). The encoded [CLS] output is passed through a linear classifier to produce logits over the nine classes. To address class imbalance, we use a focal loss objective with class weights, defined as: â=1Bââj=1B(1âpj)2â CEâ(âj,yj;Îą),L= 1B _j=1^B(1-p_j)^2¡CE( _j,y_j;Îą), where pj=eâCEâ(âj,yj;Îą)p_j=e^-CE( _j,y_j;Îą). The network is optimized with AdamW, and we apply early stopping based on the validation macro-F1 score. Integrated Gradients Attribution: To identify which input features drive the Transformerâs decisions, we employ Integrated Gradients. Given an input x and the zero-vector baseline xâ˛x , IG computes IGiâ(x)=(xiâxiâ˛)ââŤ01âFâ(xâ˛+Îąâ(xâxâ˛))âxiâÎą,IG_i(x)\;=\;(x_i-x _i)\, _0^1 â F (x +Îą(x-x ) )â x_i\,dÎą, where F denotes the trained modelâs output score for the predicted class. We sample 100 test instances, compute each oneâs predicted class, and then calculate IG attributions with respect to that class. The resulting attribution vectors are aggregated by taking their mean absolute values to produce global importance rankings. Decision Tree Surrogate & Rule Extraction: We simplify the Transformerâs behavior into an interpretable decision tree. We train a CART decision tree (maximum depth=4, minimum leaf size=40) using the Transformerâs predictions on the training data as pseudolabels. For each leaf node, we record the conjunction of feature-threshold conditions along the path from the root to form a logical clause: class(âcâ):âfi1â¤Î¸1,fi2>θ2,âŚ, class(c )\;:-\;f_i_1⤠_1,\;f_i_2> _2,\;âŚ\;, where c is the class predicted by that leaf. In a held-out test set, each instance belongs to exactly one leaf, we record the set of test indices covered by each leaf (the support set). We then compute: ⢠Coverage = fraction of test instances assigned to any leaf in a given subset. ⢠Fidelity = fraction of covered instances whose tree-predicted class matches the Transformerâs prediction. ⢠Redundancy = mean pairwise Jaccard index among all leaf support sets. Baseline Comparisons: To contextualize the Transformerâs performance, we compare it against a set of strong baseline models. This includes a Decision Tree, MLP, and powerful gradient boosting methods: Random Forest, XGBoost, LightGBM, and CatBoost. All baselines are trained on the same data and evaluated on the validation set. For LightGBM, we use class_weight=âbalancedâ to better handle class imbalance. 3.1 LLM-Mediated Explanation and Validation: The framework culminates in generating and strictly validating natural language explanations. We employ a multi-LLM approach, using four different generator models (Qwen2.5:14b, llama3.1:8b, phi4:14b, gemma3:27b) to produce explanations. The prompt for the generator includes the predicted class, the triggered logical rule, and the top 5 most influential features from Integrated Gradients. In our evaluation, we introduce a novel, three-part validation scheme to automatically assess the quality of each generated explanation: 1. Semantic Similarity: Using a pre-trained SentenceTransformer model (âall-MiniLM-L6-v2â), we calculate the cosine similarity between the vector embeddings of the original logic rule and the LLMâs text explanation. This measures how well the explanation preserves the core logical reasoning. 2. Attribution Faithfulness: We programmatically check if the explanationâs descriptive language (e.g., âhigh,â âlow,â âincreaseâ) aligns with the mathematical sign (positive or negative) of the featureâs attribution score. This ensures the explanation does not misrepresent the modelâs reasoning. 3. Actionability Score: To assess the practical utility of an explanation for a security professional, we use a separate, powerful evaluator LLM (llama3.3:70b). The evaluator is prompted to score the explanation on a 1-5 scale of actionability, from âNot Actionableâ to âVery Highly Actionable.â This provides an expert-level judgment on the explanationâs quality. 3.1.1 Prompt Design for Explanations and Evaluation To obtain consistent and high-quality outputs, we designed structured prompts for both the explanation generation and the actionability evaluation. Generation Prompt For the generator LLMs, we use a constrained prompt template that encourages the model to align its wording with the feature attribution signs. For each instance, the prompt provides (i) the predicted class label, (i) the logical rule (decision-tree clause) that fired, and (i) the top-5 most influential features with their values and Integrated Gradients attribution scores. The instructions require the model to interpret positive attributions as âhigh,â âlarge,â or âkey indicatorsâ and negative attributions as âlow,â âsmall,â or ânot a concern.â This reduces the likelihood of unsupported or contradictory statements and helps keep explanations grounded in the underlying attributions. The exact template used is shown in Figure 2. Generator Prompt Template You are a security analysis assistant. Your task is to explain why a network activity was classified as âcls_nameâ. Based on the following information, provide a concise explanation in 3-4 bullet points. Key Information: - Logical Rule Triggered: The activity matched the pattern: clause - Top-5 Most Influential Features (with their actual values and attribution scores): ig_list Instructions: - Return exactly 3-4 bullet points. - Each bullet point must start with â- â. - Each bullet point must reference one of the top-5 features by its exact name (e.g., âsample_feat_nameâ). - Each bullet point must discuss the featureâs value and its influence. - Crucially, use the sign of the âAttributionâ score to guide your language. - If a featureâs Attribution is positive, describe its value as âhigh,â âlarge,â âelevated,â or âa key indicator.â - If a featureâs Attribution is negative, describe its value as âlow,â âsmall,â âabsent,â or ânot a concern.â Example Response: - A high âip.lenâ of 1400 bytes was a key indicator for this classification. - The âtcp.time_deltaâ was unusually low at 0.001s, strongly suggesting automated activity. - The âtcp.flagsâ value of 18, while present, was noted as being less influential. Figure 2: Structured prompt template used for generating explanations. Evaluation Prompt To assess the practical utility of these explanations, we employ a separate, larger evaluator model (Llama3.3:70b) acting as an expert security analyst. The evaluator sees only the generated explanation text and is instructed to assign an actionability score on a 1â5 scale, where 1 denotes a non-actionable, generic description and 5 denotes a very highly actionable explanation that both justifies the alert and suggests a concrete next step or plausible attack type. The prompt emphasizes that high scores are reserved for explanations that provide security context rather than merely restating data values (see Figure 3). Evaluator Prompt Template You are an expert cybersecurity analyst. Your task is to evaluate an explanation for a network security alert. The Explanation to Evaluate: â explanation_text â Evaluation Criteria: On a scale of 1 to 5, how actionable is this explanation for a security professional? - 1 (Not Actionable): The explanation is generic, confusing, or simply repeats the data without context. - 2 (Slightly Actionable): It mentions a feature value but provides no security context. - 3 (Moderately Actionable): It correctly identifies a feature and links it to a general security concept (e.g., âhigh trafficâ). - 4 (Highly Actionable): It explains why a featureâs value is suspicious, using relevant security terms (e.g., âThis suggests a port scanâ). - 5 (Very Highly Actionable): It not only explains the âwhyâ but also suggests a potential attack type or a clear next step for investigation (e.g., âThe pattern is consistent with a DDoS amplification attackâ). Based on these criteria, provide a score. Your response must be only the score, in the format: âActionability Score: [score]â Figure 3: Scoring rubric prompt used for the automated evaluator. 4 Experimental Setup We evaluate the approach on a public 5G/IoT intrusion detection dataset collected on our testbed, with separate training and testing splits. The dataset contains traffic data for nine classes (eight attacks and one benign). The framework is implemented in Python using PyTorch, scikit-learn, and the Hugging Face transformers library. All experiments were conducted on a single machine equipped with an NVIDIA RTX 4090 GPU, 128 GB of RAM, and an AMD Threadripper CPU. To ensure the robustness of the findings, all model training and evaluation experiments were repeated 5 times. A detailed summary of each train and test dataset is provided in Table 1. Table 1: Summary of the Train and Test Datasets. Metric Train Dataset Test Dataset Total Records 1,753,454 194,829 Number of Features 29 29 Class Distribution Benign 1,322,254 148,070 Brute Force 291 32 DDoS 165,070 18,341 Device Spoofing 70 8 DoS_MQTT 250,514 27,835 Eavesdropping 3,525 392 MITM 677 75 SQL Injection 475 53 Unauthorized Data Access 207 23 4.1 Network Feature Set We rely on 29 packet- and flow-level features spanning frame-, IP-, TCP-, UDP-, and HTTP-layer properties. Table 2 summarizes all features and their descriptions. Table 2: Network traffic features used in the model. Feature Description HTTP Layer Features http.request.uri URI of HTTP request http.request Boolean flag for HTTP request TCP Layer Features tcp.dstport Destination port number tcp.srcport Source port number tcp.port Source or destination port tcp.time_delta Time since previous TCP segment tcp.time_relative Time since first frame tcp.reassembled.length Total reassembled payload length tcp.segments Number of segments in PDU tcp.analysis.ack_rtt Acknowledged round-trip time tcp.flags TCP flags bitmask tcp.urgent_pointer TCP urgent pointer value tcp.stream Unique TCP stream identifier tcp.len TCP payload length (bytes) tcp.seq TCP sequence number tcp.ack TCP acknowledgment number tcp.ack_raw Raw TCP acknowledgment tcp.window_size.1 TCP window size value UDP Layer Features udp.port Source or destination port udp.length UDP datagram length (bytes) IP Layer Features ip.proto Protocol number (e.g., 6=TCP) ip.ttl Time-to-live value ip.fragments Reassembled IP fragments ip.flags.mf More Fragments flag ip.flags.df Donât Fragment flag ip.len Total IP datagram length Frame Layer Features frame.time_delta Time since previous frame frame.time_relative Time since first capture 4.2 Hyperparameter Tuning To select the optimal model configurations, we performed hyperparameter tuning based on performance on the validation set. For the main Transformer IDS model, we tuned the learning rate over 10â5,10â4,10â3\10^-5,10^-4,10^-3\ and the AdamW weight decay over 10â3,10â2,10â1\10^-3,10^-2,10^-1\. The final selected values were 10â410^-4 and 10â210^-2, respectively. For the Decision Tree Surrogate, we aimed to balance fidelity with interpretability. We performed a grid search for max_depth over 3,4,5\3,4,5\ and min_samples_leaf over 20,40,60,80\20,40,60,80\. The configuration of max_depth=4 and min_samples_leaf=40 was chosen as it provided the best fidelity without creating an overly complex tree. 4.3 LLM Configuration For all LLM-based explanation generation and evaluation tasks, we used a consistent set of parameters to ensure reproducibility and deterministic outputs. The API calls were configured with a temperature of 0.1. This low value was chosen to minimize randomness and ensure that the generated explanations are factual, consistent, and grounded in the provided prompt, which is essential for a scientific and analytical task. We also set a max_tokens limit of 250 to encourage concise, focused explanations suitable for a security analystâs review and to manage computational resources. 4.3.1 Expert rating protocol In addition to the automatic, LLM-based evaluation of explanation quality, we also collected human judgements from two domain experts in network security and intrusion detection. Each expert interacted with a lightweight web-based survey interface that presented 20 explanation instances (five per generator LLM, covering both benign and attack traffic). For every instance, the experts rated the generated explanation along four 5-point Likert scales capturing structural validity, semantic consistency with the predicted class, perceived faithfulness to the described features, and practical actionability for a security analyst. These ratings are used only for evaluation (they are not fed back into the models) and provide an independent, human-centred view of explanation quality. A detailed analysis of the expert scores and their relationship to the LLM-as-judge metrics is reported in Section 5.6. 5 Results and Analysis Figure 4: ROC curves (left) and Precision-Recall curves (right) for all attack types. 5.1 Classification Performance The Transformer model achieves exceptional performance with an overall accuracy of 99.87% and a macro-averaged F1 score of 0.854. Table 3 presents detailed per-class metrics that demonstrate robust performance across all attack categories despite severe class imbalance. Figure 4 shows the ROC and Precision-Recall curves for each attack type, illustrating the modelâs discriminative power. The curves demonstrate near-perfect performance for high-volume attack classes and strong performance for rare attack types. Table 3: Per-class classification performance on test set. Attack Type Precision Recall F1-Score Support Brute Force 0.619 0.812 0.703 32 DDoS 1.000 1.000 1.000 18341 Device Spoofing 0.714 0.625 0.667 8 DoS_MQTT 1.000 1.000 1.000 27835 Eavesdropping 0.642 0.944 0.764 392 MITM 0.986 0.933 0.959 75 SQL Injection 0.978 0.830 0.898 53 Unauthorized Data Access 0.696 0.696 0.696 23 Benign 1.000 0.999 0.999 148070 Macro Avg 0.848 0.871 0.854 194829 Weighted Avg 0.999 0.999 0.999 194829 5.2 Baseline Comparison The performance of our explainable Transformer model relative to other baselines is shown in Table 4. While ensemble methods like RandomForest achieve a higher macro-F1 score, they operate as black boxes. The proposed framework provides an effective alternative, delivering high accuracy associated with good transparency. This result explicitly frames the critical trade-off for security domains: a marginal performance gain from an opaque model versus a highly performant and interpretable system. Table 4: Baseline comparison on validation set (Macro-F1). Model Macro-F1 Decision Tree (depth 4) 0.487 MLP (256-128) 0.887 XGBoost 0.966 CatBoost 0.970 LightGBM 0.980 Random Forest 0.989 Transformer (Ours) 0.854 5.3 Feature Attribution Analysis Figure 5 reveals that temporal and volumetric features dominate the modelâs decisions. frame.time_relative has the highest mean attribution score, followed by tcp.time_relative and tcp.stream. This aligns with domain knowledge that anomalies in packet timing and data flow size are key indicators of network intrusions. Figure 5: Mean absolute Integrated Gradients attribution for top network features. 5.4 Rule Extraction and Interpretability The surrogate decision tree generates 16 interpretable rules with 99.72% Âą 0.01% fidelity and 100% coverage across all runs. After pruning the single least-supported leaf, the remaining 15 rules maintain their high fidelity while still covering 99.998% of test cases. Figure 6 demonstrates that the eight highest-support rules are sufficient to explain over 99% of instances, enabling efficient rule-based deployment and analysis. Figure 6: Coverage and fidelity trade-off as rules are added in descending support order. 5.5 Multi-LLM Explanation Quality and Validation We evaluated explanations from four LLMs across a more robust set of 20 randomly sampled test instances. The aggregated results, shown in Table 5, reveal a significant difference in quality among models. While all models produced structurally valid outputs, their ability to generate faithful and actionable content varied. Qwen2.5:14b and phi4:14b emerge as top performers, achieving near-perfect attribution faithfulness scores of 0.99 and 0.98 respectively. This indicates they correctly interpret and represent the direction of influence (positive or negative) for each feature. Furthermore, both models achieved excellent average actionability scores of 4.6 and 4.5, demonstrating their ability to produce explanations that are highly useful to a security professional. In contrast, gemma3:27b had a lower faithfulness score (0.91), suggesting it sometimes struggles to correctly map attribution signs to descriptive language. This more extensive evaluation confirms that with the right model and prompting, it is possible to generate AI explanations that are consistently trustworthy and useful. Table 5: LLM Explanation Evaluation Results (Averaged over 20 test instances). Scores for Faithfulness range from 0 to 1. Actionability is scored on a scale of 1â5. Generator Struct. valid (%) Semantic similarity Attribution faithfulness Actionability (1â5) gemma3_27b 100% 0.670 0.91 3.9 llama3.1_8b 100% 0.668 0.94 4.1 phi4_14b 100% 0.678 0.98 4.5 Qwen2.5_14b 100% 0.678 0.99 4.6 An example of a high-quality explanation for a DoS_MQTT attack (ID: 60492) from phi4:14b highlights these strengths: ⢠- A high âframe.time_relativeâ of 812.4183 is a key indicator, contributing significantly to the classification of DoS_MQTT due to its high attribution score. ⢠- The âtcp.time_relativeâ value of 0.0000 is âsmallâ, aligning with expected values for this pattern and strongly supporting the DoS_MQTT classification due to its negative attribution. ⢠- A âlargeâ âtcp.streamâ count of 598269.0000 serves as a crucial factor, positively influencing the identification of DoS_MQTT activity based on its notable attribution score. This explanation is effective because it correctly uses directional language (âhigh,â âsmall,â âlargeâ), aligns perfectly with the feature attribution signs, and provides valuable security context (e.g., âhigh volume of simultaneous connections,â âsudden and rapid packet transmissionsâ). 5.5.1 Qualitative Example Explanations To complement the quantitative metrics, Table 6 presents the actual generated text from all four LLMs for two distinct scenarios: a DoS_MQTT attack and a Benign traffic instance. The table highlights the difference in semantic quality; while all models generate coherent text, the top performers (Phi4 and Qwen) use more precise directional language. An example of a high-quality explanation for a DoS_MQTT attack (ID: 60492) from phi4:14b highlights these strengths: ⢠- A high âframe.time_relativeâ of 812.4183 is a key indicator, contributing significantly to the classification of DoS_MQTT due to its high attribution score. ⢠- The âtcp.time_relativeâ value of 0.0000 is âsmallâ, aligning with expected values for this pattern and strongly supporting the DoS_MQTT classification due to its negative attribution. ⢠- A âlargeâ âtcp.streamâ count of 598269.0000 serves as a crucial factor, positively influencing the identification of DoS_MQTT activity based on its notable attribution score. This explanation is effective because it correctly uses directional language (âhigh,â âsmall,â âlargeâ), aligns perfectly with the feature attribution signs, and provides valuable security context (e.g., âhigh volume of simultaneous connections,â âsudden and rapid packet transmissionsâ). Table 6: Representative LLM-generated explanations for DoS_MQTT and benign traffic. Model Generated Explanation Record 60492: DoS_MQTT Attack Gemma3:27b ⢠A high frame.time_relative of 812.4183 was a key indicator, contributing significantly to the DoS classification. ⢠The tcp.time_relative value of 0.0000 was low and therefore not a primary driver of this classification. ⢠A large tcp.stream value of 598269.0000 suggests a high volume of connections, supporting the DoS categorization. ⢠The tcp.window_size.1 of 64.0000 was elevated, contributing to the overall assessment of potentially malicious activity. Llama3.1:8b ⢠A large frame.time_relative of 812.4183 seconds was a key indicator for this classification, indicating that the network activity occurred far into the past. ⢠The tcp.stream value of 598269.0000 was high, suggesting an elevated stream ID, which contributed to the DoS_MQTT classification. ⢠A low tcp.time_relative of 0.0000 seconds was not a concern in this context. Phi4:14b ⢠A high frame.time_relative of 812.4183 is a key indicator, contributing significantly to the classification of DoS_MQTT due to its high attribution score. ⢠The tcp.time_relative value of 0.0000 is small, aligning with expected values for this pattern and strongly supporting the DoS_MQTT classification due to its negative attribution. ⢠A large tcp.stream count of 598269.0000 serves as a crucial factor, positively influencing the identification of DoS_MQTT activity. Qwen2.5:14b ⢠A high frame.time_relative value of 812.4183 seconds was a key indicator for this classification. ⢠The tcp.time_relative value of 0.0000 seconds was low, not a concern in terms of influencing the decision. ⢠The tcp.window_size.1 value of 64 bytes was large, elevating its influence on the classification. Record 139096: Benign Traffic Gemma3:27b ⢠A low tcp.time_relative of 519.3665 contributed to the benign classification, as indicated by its negative attribution score. ⢠The tcp.port value of 44350.0000 was a key indicator of benign activity, supported by its positive attribution score. ⢠The tcp.flags value of 24.0000 was not a concern for malicious activity, given its slightly negative attribution score. ⢠An elevated tcp.stream value of 94.0000 played a role in classifying this activity as benign. Llama3.1:8b ⢠A high tcp.time_relative value of 519.3665 indicates that the network activity is likely to be benign due to its prolonged duration. ⢠The tcp.port of 44350 was a large contributor to this classification, indicating a potential legitimate service or application. ⢠The absent influence of tcp.flags, with an attribution score of -0.093, suggests that the network activity does not exhibit suspicious flag settings. Phi4:14b ⢠The tcp.time_relative value of 519.3665 is considered low, indicating that the timing of this packet relative to others in the session does not raise concern and aligns with benign behavior. ⢠A high tcp.port of 44350.0000 serves as a key indicator for classification, suggesting typical usage patterns such as secure web traffic. ⢠The tcp.flags value of 24.0000 was noted to be less influential, reinforcing the activityâs non-threatening nature. Qwen2.5:14b ⢠The tcp.time_relative value of 519.3665 seconds was considered low, indicating minimal concern for this classification. ⢠A tcp.port value of 44350 was considered a standard port assignment, contributing positively to the benign assessment. ⢠The tcp.flags value of 24 had a minor influence as it was less critical in determining the activityâs nature. 5.6 Expert Study of Explanation Quality To complement the automatic evaluation of explanation quality in Section 5.5, we conducted a small expert study to obtain a human-centered assessment of the generated explanations. The goal was to understand how security professionals perceive different generator LLMs along dimensions closely aligned with our automatic metrics (semantic similarity, attribution faithfulness, and actionability), and to test whether the LLM-as-judge scores approximate expert judgements. Participants and task We collected responses from two domain experts in network security and intrusion detection. The first expert has over ten years of professional experience, and the second expert has between five and ten years of experience. Both experts interacted with the same web-based interface, which, for each survey item, presented the record identifier, the predicted class (benign, DDoS, or DoS_MQTT), the generator LLM, and the corresponding natural language explanation. For each explanation, the experts provided ratings on four 5-point Likert scales (1 = very poor, 5 = very high): ⢠Structural validity (m1): how well-formed, coherent, and readable the explanation is. ⢠Semantic consistency (m2): how well the explanation matches the stated class and the described traffic pattern. ⢠Faithfulness (m3): how well the explanation appears to focus on the salient features it mentions, without introducing irrelevant or contradictory factors. ⢠Actionability (m4): how useful the explanation would be for a security analyst deciding whether and how to respond. These four dimensions mirror the goals of the automatic evaluation: semantic similarity (semantic consistency), attribution faithfulness (faithfulness), and evaluator-LLM actionability (actionability), while also capturing general linguistic quality (structural validity). Materials The study utilized a total of 20 explanation instances. For each of the four generator models considered in Section 5.5 (Qwen2.5:14b, Gemma3:27b, Llama3.1:8b, Phi4:14b), we sampled five explanations covering both benign and attack traffic (DDoS and DoS_MQTT). Each item, therefore, corresponds to a unique combination of record, predicted class, and generator model. Both experts rated all 20 items, resulting in 40 explanationâannotator pairs and 160 scalar ratings in total (20 items Ă 2 experts Ă 4 metrics). Overall results Averaged over all explanations and both experts, the mean scores on the 1â5 scale are: ⢠Structural validity (m1): 4.0 ⢠Semantic consistency (m2): 3.6 ⢠Faithfulness (m3): 3.7 ⢠Actionability (m4): 3.6 These moderate-to-high ratings indicate that, from a two-expert perspective, the LLM-generated explanations are generally perceived as understandable and reasonably useful, but still leave room for improvement, particularly in faithfully reflecting the underlying model behaviour and in providing highly actionable guidance. Per-model analysis and comparison with LLM-based metrics Table 7 compares the expertsâ average ratings per generator model to the automatic metrics reported in Section 5.5 for the same set of models. For each generator LLM, we report the mean structural validity, semantic consistency, faithfulness, and actionability across both experts (all 1-5), alongside the semantic similarity, attribution faithfulness (0-1), and evaluator-LLM actionability score (1-5) used in the LLM-as-judge evaluation. Table 7: Comparison of two-expert ratings (1-5) with automatic LLM-based metrics from the multi-LLM evaluation. Human ratings are averaged over five explanations per generator model, rated independently by two experts (10 ratings per model and metric). Semantic similarity and attribution faithfulness range from 0 to 1, while actionability is on a 1-5 scale. Human experts (1â5) Automatic LLM-based metrics Generator LLM Struct. Sem. Faith. Act. Sem. sim. Attr. faith. Act. (1â5) Gemma3:27b 4.4 3.4 3.3 3.4 0.670 0.91 3.9 Llama3.1:8b 3.4 3.5 3.3 3.3 0.668 0.94 4.1 Phi4:14b 4.4 3.7 4.1 4.1 0.678 0.98 4.5 Qwen2.5:14b 3.8 3.7 3.9 3.5 0.678 0.99 4.6 The experts consistently rate all models as structurally sound (scores between 3.4 and 4.4), which is in line with the automatic structural validity metric reporting 100% valid outputs for all four LLMs. Phi4:14b and Gemma3:27b obtain the highest structural validity scores (4.4), while Qwen2.5:14b and Llama3.1:8b are slightly lower but still comfortably above the midpoint. For semantic consistency and faithfulness, the human ratings are more differentiated than the automatic scores. Phi4:14b achieves the highest faithfulness (4.1) and also strong semantic consistency (3.7), followed closely by Qwen2.5:14b (3.9 faithfulness, 3.7 semantic consistency). Gemma3:27b and Llama3.1:8b obtain more moderate scores around 3.3â3.5. Interestingly, despite all four models achieving high automatic attribution faithfulness (0.91-0.99), the experts perceive more variation, suggesting that faithfulness, as inferred from the attribution signal, and faithfulness, as perceived from the explanation text, are related but not identical. Regarding actionability, the evaluator LLM produces relatively high scores for all models (3.9-4.6), whereas the human experts are more conservative, with ratings ranging from 3.3 to 4.1. Phi4:14b again stands out with the highest human actionability score (4.1), broadly consistent with its strong automatic actionability score. The other models cluster closely behind, with Qwen2.5:14b at 3.5 and Gemma3:27b and Llama3.1:8b at 3.4 and 3.3, respectively. Although this study still involves a small sample of two experts and 20 explanation instances, it provides a useful sanity check and qualitative complement to the LLM-as-judge metrics. First, all four LLMs produce explanations that are judged as at least moderately coherent, semantically aligned, and actionable by practitioners. Second, the comparison in Table 7 highlights that automatic scores tend to be slightly more optimistic and that model rankings can differ between human and LLM evaluators, especially for faithfulness and semantic alignment. This highlights the importance of retaining a human-in-the-loop perspective when deploying explanation systems in critical 5G security settings. Future work will extend this study to more analysts and a larger set of explanations to quantify inter-rater agreement and to further probe the alignment between automated and human-centred evaluation of explanation quality. 5.7 Computational Efficiency The system achieves excellent efficiency with a median inference latency of 2.48 ms per flow on a CPU. This high throughput enables real-time deployment in demanding 5G network environments without requiring specialized hardware. Figure 7: Inference latency distribution for the Transformer model (200 test samples). 6 Discussion The results prompt a critical discussion on AI performance in cybersecurity. The baseline comparison clearly shows that unclear ensemble models, such as RandomForest, can achieve a higher macro-F1 score than the Transformer-based model. A purely academic, metric-driven perspective might interpret this as a weakness. However, from an operational standpoint, this result is the central strength and argument of the work. In a security operations center, an analyst faced with an alert from a black-box model confronts a dilemma: trust the alert without understanding its basis or ignore it, risking a breach. This trust deficiency can make even the highest-performing models operationally useless. The ExAI5G framework confronts this problem directly. We demonstrate that it is possible to build a system that is both highly accurate (99.9%) and completely transparent. The slight difference in F1-score is a necessary trade-off for achieving full interpretability, which is arguably essential for systems deployed in critical 5G infrastructure. The real success of the proposed framework is not simply about surpassing the baseline F1-score; itâs about offering a reliable and trustworthy alternative. Every decision made by this system can be deconstructed into a simple logical rule, grounded in feature attributions, and expressed in natural language that we have quantitatively proven to be faithful and actionable. This shifts the discussion from narrowly optimizing metrics to a more advanced conversation about creating AI systems that are robust, reliable, and worthy of human trust. 7 Limitations and Future Work While this framework successfully integrates performance and interpretability, we recognize several limitations that provide opportunities for future research. Limitations: ⢠Dataset Scope: The evaluation is conducted on a single, collected comprehensive, 5G/IoT dataset. The performance and the extracted rules may not generalize perfectly to different network environments. ⢠Surrogate Model Fidelity: While the surrogate decision tree achieves high fidelity (99.72%), it is not a perfect one-to-one mapping of the Transformer model. A small fraction of the deep modelâs decisions are not captured by the logic rules, indicating a remaining area of opacity. ⢠Adversarial Robustness: The very transparency of the system could be a vector for attack. An adversary with knowledge of the extracted rules could potentially craft malicious traffic specifically designed to evade detection. The adversarial robustness of this explanation-driven framework has not yet been evaluated. Future Work: Building on these limitations, we propose several directions for future work: ⢠Cross-Dataset Validation: To ensure generalizability, the ExAI5G framework should be tested on a wider variety of datasets from different 5G core network vendors and IoT deployment scenarios. ⢠Enhancing Explanation Faithfulness: Future research could explore more complex surrogate models, such as rule ensembles or programmatic rule induction techniques, to close the fidelity gap while maintaining interpretability. ⢠Adversarial Defense for XAI: A critical next step is to investigate the systemâs vulnerability to explanation-aware adversarial attacks and to develop corresponding defense mechanisms, potentially by introducing a degree of randomness or ensemble-based explanations. ⢠Automated Rule-to-Response Pipelines: The high-fidelity logical rules generated by the system are well-suited for automated security orchestration. Future work could focus on building pipelines that automatically translate these rules into active defense policies, such as generating firewall rules or SIEM correlation searches. 8 Conclusion This work introduced ExAI5G, an explainable AI framework designed to bring transparency to intrusion detection in 5G networks. We have demonstrated that it is not necessary to accept the opacity of high-performing models as an unavoidable trade-off. The proposed Transformer-based system achieves 99.9% accuracy and extracts a set of 16 logical rules that represent its decision-making process with 99.7% fidelity. The central contribution of this paper is not the creation of another high-scoring IDS, but the presentation of a holistic, trustworthy system. The use of prioritizing explainability in our method directly addresses the critical gap between AI models and the human operators who must rely on them. The novel, quantitative validation of LLM-generated explanations further ensures that this transparency is meaningful and actionable. Finally, ExAI5G proves that the most effective IDS for a critical domain is not necessarily the one with the highest F1-score, but the one whose performance is matched by its ability to be understood, verified, and trusted. Acknowledgements This work was supported by the Research Council of Finland through the 6G Flagship program (grant 318927), the Strategic Research Council affiliated with Academy of Finland through the CO2CREATION project (grant 372355), by Business Finland through the Neural pub/sub research project (diary number 8754/31/2022), and by the ERDF (project numbers A81568, A91867). CRediT authorship contribution statement Saeid Sheikhi: Conceptualization, Methodology, Software, Data curation, Formal analysis, Investigation, Visualization, Writing, original draft. Panos Kostakos: Supervision, Project administration, Validation, Writing, review & editing. Lauri LovĂŠn: Supervision, Validation, Writing, review & editing, Funding acquisition. Ethics statement The network traffic dataset used in this study was collected in a fully controlled 5G testbed without real user traffic or personally identifiable information. All attack scenarios were synthetically generated for research purposes. The expert evaluation in Section 5.6 involved two adult security professionals who participated voluntarily and provided informed consent. No personally identifiable or sensitive information about the experts was collected, and the ratings are reported only in aggregate form. Declaration of competing interest The authors declare that they have no conflicts of interest about this study. References [1] A. Bilal, D. Ebert, and B. Lin (2025) Llms for explainable ai: a comprehensive survey. arXiv preprint arXiv:2504.00125. Cited by: §2. [2] F. Charmet, H. C. Tanuwidjaja, S. Ayoubi, P. Gimenez, Y. Han, H. Jmila, G. Blanc, T. Takahashi, and Z. Zhang (2022) Explainable artificial intelligence for cybersecurity: a literature survey. Annals of Telecommunications 77 (11), p. 789â812. Cited by: §1, §2. [3] V. Contreras, M. Schumacher, and D. Calvaresi (2024) Explanation of deep learning models via logic rules enhanced by embeddings analysis, and probabilistic models. In International Workshop on Explainable, Transparent Autonomous Agents and Multi-Agent Systems, p. 155â183. Cited by: §2. [4] M. Craven and J. Shavlik (1995) Extracting tree-structured representations of trained networks. Advances in neural information processing systems 8. Cited by: §2. [5] Y. Fan, Y. Li, M. Zhan, H. Cui, and Y. Zhang (2020) Iotdefender: a federated transfer learning intrusion detection framework for 5g iot. In 2020 IEEE 14th international conference on big data science and engineering (BigDataSE), p. 88â95. Cited by: §1, §2. [6] D. Gaspar, P. Silva, and C. Silva (2024) Explainable ai for intrusion detection systems: lime and shap applicability on multi-layer perceptron. IEEE Access. Cited by: §2. [7] R. Guidotti, A. Monreale, S. Ruggieri, F. Turini, F. Giannotti, and D. Pedreschi (2018) A survey of methods for explaining black box models. ACM computing surveys (CSUR) 51 (5), p. 1â42. Cited by: §2. [8] S. Gyawali, J. Huang, and Y. Jiang (2024) Leveraging explainable ai for actionable insights in iot intrusion detection. In 2024 19th Annual System of Systems Engineering Conference (SoSE), p. 92â97. Cited by: §2. [9] Y. Kim, Y. Kim, and H. Kim (2022) Effective feature selection methods to detect iot ddos attack in 5g core network. Sensors 22 (10), p. 3819. Cited by: §2. [10] I. Linkov, S. Galaitsi, B. D. Trump, J. M. Keisler, and A. Kott (2020) Cybertrust: from explainable to actionable and interpretable artificial intelligence. Computer 53 (9), p. 91â96. Cited by: §1, §2. [11] M. Nyre-Yu, E. Morris, M. Smith, B. Moss, and C. Smutz (2022) Explainable ai in cybersecurity operations: lessons learned from xai tool deployment.. Technical report Sandia National Lab.(SNL-NM), Albuquerque, NM (United States). Cited by: §2. [12] P. Radoglou-Grammatikis, G. Nakas, G. Amponis, S. Giannakidou, T. Lagkas, V. Argyriou, S. Goudos, and P. Sarigiannidis (2023) 5GCIDS: an intrusion detection system for 5g core with ai and explainability mechanisms. In 2023 IEEE Globecom Workshops (GC Wkshps), p. 353â358. Cited by: §1. [13] S. Sheikhi and P. Kostakos (2023) DDoS attack detection using unsupervised federated learning for 5g networks and beyond. In 2023 Joint European Conference on Networks and Communications & 6G Summit (EuCNC/6G Summit), p. 442â447. Cited by: §1. [14] M. Siganos, P. Radoglou-Grammatikis, I. Kotsiuba, E. Markakis, I. Moscholios, S. Goudos, and P. Sarigiannidis (2023) Explainable ai-based intrusion detection in the internet of things. In Proceedings of the 18th international conference on availability, reliability and security, p. 1â10. Cited by: §2. [15] K. Sood, M. R. Nosouhi, D. D. N. Nguyen, F. Jiang, M. Chowdhury, and R. Doss (2023) Intrusion detection scheme with dimensionality reduction in next generation networks. IEEE Transactions on Information Forensics and Security 18, p. 965â979. Cited by: §2. [16] O. Subasi, J. Cree, J. Manzano, and E. Peterson (2024) A critical assessment of interpretable and explainable machine learning for intrusion detection. arXiv preprint arXiv:2407.04009. Cited by: §1. [17] M. Sundararajan, A. Taly, and Q. Yan (2017) Axiomatic attribution for deep networks. In International conference on machine learning, p. 3319â3328. Cited by: §1. [18] J. R. Zilke, E. Loza MencĂa, and F. Janssen (2016) Deepredârule extraction from deep neural networks. In Discovery Science: 19th International Conference, DS 2016, Bari, Italy, October 19â21, 2016, Proceedings 19, p. 457â473. Cited by: §2.