NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Leveraging Large Language Models with Chain-of-Thought and Prompt Engineering for Traffic Crash Severity Analysis and Inference

Hao Zhen, Yucheng Shi, Yongcan Huang, Jidong J. Yang, Ninghao Liu

TL;DR

This paper explores using Large Language Models (LLMs) like GPT-3.5 and LLaMA3 for traffic crash severity analysis. By converting structured crash data into narratives and employing Chain-of-Thought (CoT) prompting, they found LLMs can effectively infer crash severity, with LLaMA3-70B showing the best performance, especially in zero-shot scenarios.

What Problem Does This Paper Address?

Traditional methods for analyzing traffic crash severity often rely on structured, numerical data and can struggle with the complex, multifaceted nature of accidents. These methods can also be limited by specific functional forms and distributional assumptions. While natural language processing (NLP) has been applied to crash narratives, it typically requires large, labeled datasets, which are costly and time-consuming to obtain. This paper addresses the challenge of leveraging the advanced comprehension and generation capabilities of LLMs for traffic crash analysis, aiming to overcome the limitations of traditional methods and the data-intensive nature of existing NLP approaches. Specifically, it tackles two main issues: (1) ensuring LLMs understand the domain knowledge and causality behind crash events, and (2) bridging the "alignment gap" where LLMs, trained on general internet data, need to be specialized for analyzing specific textual data from crash reports.

Methods

The researchers employed a multi-pronged approach to enable LLMs to perform crash severity inference:

  • Textual Narrative Generation: Raw tabular crash data was transformed into human-readable textual narratives using a pre-built template infused with domain knowledge. This makes the data more digestible for LLMs.
  • Chain-of-Thought (CoT) Prompting: To enhance reasoning capabilities and provide explainable insights, CoT was integrated. This technique guides the LLM through a step-by-step reasoning process before arriving at a final answer, allowing for a more transparent understanding of its decision-making.
  • Prompt Engineering (PE): To address the alignment gap and improve performance on the specific task of crash severity inference, carefully crafted prompts were designed. This included a novel approach of rephrasing the "Fatal accident" label to "Serious accident with potentially fatal outcomes" to mitigate LLM alignment constraints that discourage discussing sensitive topics like death.
  • In-Context Learning: Both zero-shot (no examples) and few-shot (a few examples) learning settings were explored to evaluate the LLMs' ability to perform the task with varying levels of contextual guidance.

The study evaluated three state-of-the-art LLMs: GPT-3.5-turbo, LLaMA3-8B, and LLaMA3-70B.

Datasets

The study utilized a dataset from CrashStats in Victoria, Australia, spanning from 2006 to 2020. This dataset contains records of vehicles involved in crashes, with severity coded on a four-point ordinal scale: non-injury, other injury (minor injury), serious injury, and fatal. Due to the extremely low representation of non-injury accidents, they were merged with minor injury accidents. The final dataset used for evaluation comprised 197,425 minor or non-injury accidents, 89,925 serious injury accidents, and 4,760 fatal accidents. For experimental evaluation, a smaller, balanced subset of 150 samples (50 from each severity category) was randomly drawn.

Key Insights and Ideas

  • LLMs as Viable Tools for Crash Analysis: The study demonstrates that LLMs, when appropriately prompted and guided, can effectively perform crash severity inference, offering a promising alternative to traditional methods.
  • The Power of CoT for Explainability: Chain-of-Thought prompting not only improved performance but also provided valuable insights into the LLMs' reasoning processes. The word clouds generated from CoT responses revealed that LLMs consider a wide range of factors, including crash characteristics, environmental conditions, and driver behavior, when inferring severity.
  • Prompt Engineering for Alignment: The "softening" of the "Fatal accident" label to "Serious accident with potentially fatal outcomes" was a crucial prompt engineering technique that helped LLMs overcome their alignment constraints and improve the detection of severe outcomes.
  • LLaMA3-70B's Superiority: The largest LLaMA3 model consistently outperformed GPT-3.5 and LLaMA3-8B, particularly in zero-shot settings, highlighting the benefit of model scale for this task.
  • CoT and PE Synergy: Both CoT and PE individually enhanced performance, but their combination, especially in zero-shot settings, showed potential for further improvements, particularly for identifying more severe crashes.

Key Results

  • LLaMA3-70B Dominance: LLaMA3-70B achieved the highest macro F1-score (0.4755) and macro-accuracy (49.33%) in the zero-shot with prompt engineering (ZS_PE) setting. It also performed strongly in the zero-shot with Chain-of-Thought (ZS_CoT) setting.
  • Performance Gains from CoT and PE: Both CoT and PE techniques consistently improved performance across all models compared to plain zero-shot settings, as evidenced by increases in Macro F1-score and Macro-accuracy.
  • Fatal Accident Detection Improvement: Prompt engineering, specifically the rephrased label, significantly boosted the detection of fatal accidents. For instance, GPT-3.5's accuracy for fatal accidents rose from 0% to 62% with PE.
  • Model Size Matters: Larger models generally performed better, but smaller models like LLaMA3-8B showed significant gains from few-shot learning.
  • CoT Reasoning Insights: Word clouds from CoT responses revealed LLMs consider diverse factors like "collision," "intersection," "vehicle," "driver," environmental conditions, and driver behavior in their severity inferences. For fatal accidents, terms like "head-on," "high-impact," and "excessive speed" were prominent.

Limitations and Future Work

  • Limited Dataset Size: The study acknowledges that the relatively small sample size (150 instances) may limit the generalizability of the findings and might not fully capture the complexity of real-world crash scenarios.
  • Future Research Directions:
    • Expanding the dataset to include more diverse samples for a more comprehensive evaluation.
  • Fine-tuning LLMs with domain-specific data (crash reports) to enhance their specialized knowledge.
  • Investigating explanation methods in conjunction with LLMs to yield more interpretable and trustworthy results.

Summary updated

BibTeX
@inproceedings{zhen2024leveraging,
  author = {Hao Zhen and Yucheng Shi and Yongcan Huang and Jidong J. Yang and Ninghao Liu},
  title = {{Leveraging Large Language Models with Chain-of-Thought and Prompt Engineering for Traffic Crash Severity Analysis and Inference}},
  booktitle = {Comput},
  year = {2024},
  url = {https://openreview.net/forum?id=EUJQrA0yxO},
}
Figure