Leveraging Few-Shot In-Context Learning for Scaling Railway Log Anomaly Detection

Read full text
Authors: Quentin Possamai, Rajesh Bonangi, Alexandre Trilla, Ossee Yiboe, Kenza Saiah, Nenad Mijatovic
Cited by: 0

Abstract

This paper presents a scalable, data-driven approach for anomaly detection in railway signaling logs using Large Language Models (LLMs) and in-context learning. By classifying log keys — the structural templates of log messages — instead of individual messages, the method dramatically reduces the number of required model calls, thereby lowering computational costs (in terms of energy or monetary resources). Expert-labeled log keys are incorporated into LLM prompts to help the models differentiate between normal and abnormal log messages. Multiple state-of-the-art LLMs are evaluated on this task, revealing that performance increases as more labeled examples are added to the prompt, although the improvement gain diminishes with each additional label. Further analysis indicates that GPT-4.1 offers the best balance of monetary cost, response time, and F1 score for this application. The study highlights both the advantages and limitations of in-context learning for railway log anomaly detection, notably its ability to leverage expert-labeled examples without additional model training, but also its sensitivity to data imbalance and exclusion of parameter values. It further discusses avenues for future improvement, such as model fine-tuning, prompt enrichment with additional contextual information, and the potential use of Retrieval-Augmented Generation (RAG) or self-feedback strategies to enhance classification performance.

Fields of Study & Subjects

Software System Performance and Reliability Anomaly Detection Techniques and Applications Topic Modeling

Publication details

Journal / source
PHM Society Asia-Pacific Conference
Volume
5
Issue
1
Publication date
13 January 2026