# Toward Generative AI-Based Intrusion Detection Systems for the Internet of Vehicles (IoV)
## 4 Generative AI-Based IDS for IoV
### Contextual Suitability of Generative Models  
The performance of generative models in Intrusion Detection Systems for the Internet of Vehicles greatly depends on the specific operational constraints and architectural settings of the vehicular environment. In this section, we examine the contextual suitability of three widely used generative approaches--GANs, Transformers, and VAEs--by evaluating their alignment with four critical IoV requirements: real-time latency, robustness under network variability, hardware compatibility, and memory/computation constraints. In latency-sensitive scenarios such as V2V and V2I communications, real-time detection is essential to avoid cascading system failures or collisions. Transformers, owing to their parallel processing and efficient attention mechanisms, are well suited for such tasks, especially when optimized. VAEs, while not designed for real-time classification per se, offer low-latency inference via reconstruction error and are typically faster than GANs. In contrast, GANs--due to their dual-network architecture and adversarial training--are generally unsuitable for strict real-time applications unless significantly simplified. When it comes to robustness under varying network conditions, Transformers excel because they can learn contextual dependencies across long input sequences and adapt to changing input patterns. VAEs are also resilient, particularly in unsupervised settings where they can flag deviations from the learned normal distribution. GANs, however, often require high-quality, balanced data to maintain stability; their performance can deteriorate in noisy, heterogeneous vehicular environments. From a hardware compatibility standpoint, VAEs are the most efficient and deployable, given their relatively lightweight structure and low computational footprint. Transformers, especially when compressed or fine-tuned, can also operate on edge devices, although their initial model size may require optimization. GANs are the most demanding and often need offloading to more powerful computing platforms unless aggressively pruned or simplified. Regarding memory and computational constraints, VAEs again offer a practical solution for in-vehicle or roadside deployment due to their minimal resource requirements. Transformers fall in the moderate range but are increasingly viable due to edge-friendlyvariants. GANs are the least favorable, requiring high memory and prolonged training time to maintain stable generator-discriminator dynamics. A summary of this contextual analysis is provided in Table 8, highlighting the strengths and limitations of each generative model type across the four identified criteria. Although these models show promise, each comes with specific limitations. GANs frequently suffer from mode collapse, where the generator outputs limited variation, reducing the ability of IDS to detect diverse threats. Several studies, including [70; 71], report that GANs perform poorly with imbalanced or low-quality data, potentially generating unrealistic or repetitive patterns and failing to generalize to new attacks. Transformer-based models, such as CAN-Former [78] and IoV-BERT-IDS [85], demonstrate high accuracy due to their attention mechanisms and ability to model long-range dependencies. However, studies such as [81; 83] acknowledge that large-scale models like Mistral-7B and LLAMA-2 deliver superior performance but come at the cost of extensive memory consumption, long pretraining times, and limited real-time viability on vehicle-grade hardware. Even with edge-optimized versions, deployment remains challenging in constrained environments. VAEs, while lightweight and well-suited for edge devices, have their own vulnerabilities. As demonstrated In Refs. [87; 88], VAEs may suffer from latent space collapse, where different inputs are mapped to nearly identical latent vectors, degrading the model's ability to distinguish between benign and malicious behaviors.