Retrieval Augmented Generation-based Large Language Models for Bridging Transportation Cybersecurity Legal Knowledge Gaps

Khandakar Ashrafi Akbar, Md Nahiyan Uddin, Latifur Khan, Trayce Hockstad, Mizanur Rahman, Mashrur Chowdhury, Bhavani ThuraisinghamarXiv 2025

TL;DR

This paper introduces a domain-specific Retrieval-Augmented Generation (RAG) framework designed to help policymakers navigate the rapidly evolving legal landscape of transportation cybersecurity. By grounding a Large Language Model (LLM) in a meticulously curated dataset of federal and state statutes, the system drastically reduces hallucinations and outperforms leading commercial LLMs in factual accuracy.

What Problem Does This Paper Address?

As connected and automated vehicles become mainstream, they bring massive data privacy and cybersecurity risks due to their reliance on complex IoT networks. Policymakers must constantly update legal codes to address these vulnerabilities, but keeping track of shifting regulations across all 50 states is a monumental task.

While Large Language Models (LLMs) seem like the perfect tool to accelerate this legal research, they suffer from a fatal flaw: hallucination. When queried about highly specialized, newly enacted, or jurisdiction-specific legal data, standard commercial LLMs frequently generate plausible-sounding but entirely fabricated legal statutes. Retraining these multi-billion-parameter models every time a state passes a new law is computationally and financially impractical.

Figure 1: Hallucination in Large Language Models

Methods

To solve this, the authors built a context-augmented language generation pipeline using Retrieval-Augmented Generation (RAG). Instead of relying on the LLM's static internal knowledge, the system dynamically retrieves relevant legal text chunks from an external database to answer user queries. The technical stack leverages LlamaIndex for data framework management, OpenAI’s text-embedding-ada-002 for generating vector embeddings, and gpt-3.5-turbo as the core response generator.

The authors designed and compared two distinct retrieval architectures:

  1. Whole Data Index (WDI): A global approach where the entire multi-state dataset is indexed into a single vector database. The system searches across all states simultaneously to find the top-k most relevant chunks.
  2. State-Wise Index (SWI): A targeted approach that first analyzes the user's query to detect specific state names (e.g., "Alabama" or "Kansas"). It then routes the query only to the corresponding localized state indices before aggregating the individual responses into a final answer.
Architectural Overview of RAG

Datasets

Rather than relying on automated web scraping, the authors utilized a highly specialized dataset manually curated by a licensed attorney using the LexisNexis legal research platform.

  • Legislative Documents: A total of 1,795 documents (spanning 2012 to the present) covering core cybersecurity areas like data breaches, criminal use of computers, denial of service, ransomware, and trade secrets. This includes 86 federal documents, 1,704 state documents (representing all 50 states), and 5 international documents.
  • Evaluation Benchmark: A custom Q&A dataset consisting of 59 complex, real-world legal queries targeted at transportation cybersecurity issues (e.g., determining liability if a passenger's credit card details are stolen from an autonomous vehicle), paired with expert-curated ground truth answers.

Key Insights and Ideas

  • Context Contamination is Real: In global search architectures (WDI), queries involving multiple states often suffer from mixed contexts, leading the LLM to misidentify relevant jurisdictions. The State-Wise Index (SWI) solves this by isolating the search space to specific states mentioned in the prompt.
  • Parallel Aggregation Doesn't Mean High Latency: Intuitively, querying multiple individual state indexes and merging their outputs should increase latency. However, the authors found that because the search space per retriever is drastically smaller, the overall processing overhead for SWI is negligible compared to searching the entire database at once.
  • Commercial Models Falter on Local Law: When tested against specific state codes (like Alabama's computer tampering laws), commercial models like ChatGPT-4o and Claude often hallucinated generic definitions or explicitly refused to answer, citing an inability to guarantee accurate legal information. Grounded RAG systems are mandatory for high-stakes legal compliance.

Key Results

The RAG-powered framework was evaluated against four baseline commercial models (ChatGPT-3.5, ChatGPT-4o, Google Gemini, and Anthropic Claude) using four advanced NLP metrics:

  • AlignScore (Factual Consistency): The RAG framework achieved the highest score of 0.73201, outperforming ChatGPT-4o (0.71040) and Claude (0.66579).
  • ParaScore (Paraphrase Quality): The framework scored 0.70433, significantly higher than Claude (0.66195) and Gemini (0.57926).
  • ROUGE-L (F1-Score): The RAG system reached 0.37340, clearly outperforming ChatGPT-4o's score of 0.29307.
  • SWI vs. WDI Efficiency: For complex queries comparing multiple states, the SWI method successfully identified the correct jurisdictions and answered in 23.12 seconds, whereas the WDI method took 18.03 seconds but failed to correctly identify the states.

Limitations and Future Work

The primary limitation identified is the lack of a dedicated module for automatically comparing and contrasting conflicting responses across different legislative bodies—a critical step for identifying true legal loopholes.

To address this, the authors plan to develop automated cross-jurisdictional comparison tools and establish an automated pipeline to ingest and index newly amended state legislations annually. They also aim to refine prompt engineering techniques to better guide non-legal users in structuring free-style queries effectively.

Summary updated

BibTeX
@misc{akbar2025retrieval,
  author = {Khandakar Ashrafi Akbar and Md Nahiyan Uddin and Latifur Khan and Trayce Hockstad and Mizanur Rahman and Mashrur Chowdhury and Bhavani Thuraisingham},
  title = {{Retrieval Augmented Generation-based Large Language Models for Bridging Transportation Cybersecurity Legal Knowledge Gaps}},
  year = {2025},
  eprint = {2505.18426},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.18426},
}
Figure