Skip to Content
InformationInformation
  • Article
  • Open Access

27 February 2026

23 Pages

Investigating the Impact of Log-Sequence Embeddings on Anomaly Detection: A Systematic Study

Department of Computer Science, Al-Baha University, Al-Baha 65779, Saudi Arabia
This article belongs to the Section Artificial Intelligence

Abstract

Operational logs are a central information source for monitoring and diagnosing complex information systems, yet the effect of log-sequence representation on anomaly detection remains underexplored. This paper investigates three families of sequence embeddings, E1 (template-ID lookup), E2 (semantic), and E3 (hybrid), for log-based anomaly detection. Each embedding is paired with CNN, LSTM, and Transformer heads under a unified training protocol. We conduct controlled experiments on diverse public corpora to assess in-domain and cross-dataset generalization. We report PR–AUC (primary), AUROC, F1, and precision at recall ≥0.9, with 95% bootstrap confidence intervals. Beyond accuracy, we analyze the impact of sequence length, parser choice, and out-of-vocabulary (OOV) rates at both token and template levels within and across datasets. The results suggest that representation choice can meaningfully influence detection performance, particularly under distribution shift. Open-vocabulary semantic and hybrid embeddings can improve robustness to OOV effects, but transfer gains are inconsistent, and degradation often persists under strict cross-dataset transfer.

1. Introduction

Analyzing runtime log data is a cornerstone quality assurance practice for large, distributed software systems [1,2]. Logs capture fine-grained behavior as services are executed in production, covering control flow, resource usage, and exceptional conditions, and therefore provide early signals of abnormal behavior. Effective log analysis enables timely anomaly detection, reduces mean time to detect and repair, and improves overall reliability and availability [3,4].
Modern platforms emit massive volumes of heterogeneous, largely unstructured text logs [1,2]. To make this data tractable, practitioners commonly parse raw lines into structured events consisting of a template and its parameters [3,5]. This structuring exposes an event vocabulary and turns the raw stream into sequences of template identifiers with timestamps, a practical foundation for monitoring, alerting, and troubleshooting.
Automatic log-based anomaly detection has advanced rapidly. Supervised and self-supervised models (e.g., recurrent, convolutional, and Transformer architectures) have reported strong results on public and industrial datasets [6,7,8,9,10,11]. A central design choice in these approaches is one that addresses how to embed sequences of log templates into vectors a model can learn from. In practice, three families are prevalent: (i) template-ID embeddings that assign a learned vector per template; (ii) semantic/textual embeddings that encode the template string via a pretrained language model; and (iii) hybrid schemes that combine distributional word vectors with lexical weighting (e.g., FastText + TF–IDF) [1]. Despite widespread use, there is a lack of a controlled, apples-to-apples comparison where datasets, sequence construction, model heads, and training protocols are held constant.
This paper addresses this gap with a controlled evaluation across three representative datasets: HDFS, BGL, and Thunderbird. We hold preprocessing, chronological splits, loss functions, and optimization fixed while varying only (a) the embedding strategy and (b) the downstream head (CNN, LSTM, and a Transformer). The study is organized around two research questions:
1.
RQ1 (in-domain): Which log-sequence embedding strategy (template-ID, semantic, hybrid) yields the best anomaly-detection performance when architecture and training are controlled?
2.
RQ2 (cross-dataset): Do the RQ1 findings generalize across datasets (i.e., how well do models trained on one corpus transfer to another without retraining)?
Beyond these core questions, we report (i) window-length sensitivity, (ii) a parser robustness check (Drain vs. Spell) to contextualize downstream results, and (iii) a quantitative analysis of vocabulary shift via token- and template-level out-of-vocabulary (OOV) rates. All metrics include 95% bootstrap confidence intervals for transparency and statistical stability.
By isolating representation from architecture and training recipe, our results clarify when simple ID embeddings suffice, when semantic information provides measurable gains, and how these conclusions hold under dataset and domain shifts. The goal is to provide clear, reproducible guidance for both researchers and practitioners who rely on log sequences for dependable anomaly detection.
In the remainder of this paper, Section 2 situates our work among prior research. Section 3 details the datasets, sequence construction, embeddings, heads, training protocol, and metrics. Section 4 presents the in-domain and cross-dataset results, including those of the sensitivity and robustness analyses. Section 5 discusses implications and threats to validity, and Section 6 concludes the paper with key takeaways and directions for future work.

2. Background and Related Work

2.1. Logs, Templates, and Sequences

System logs may be handled as raw free text (heterogeneous and noisy) or as parsed records in which variable tokens are masked (e.g., replaced by *) and only the stable event template (structure) is retained. Figure 1 illustrates this masking process: dynamic fields (e.g., IDs, paths) are abstracted to *, yielding a canonical template that is assigned a template ID (log key) for downstream sequencing. Parsing normalizes free text into discrete templates (optionally with parameters), enabling counting, sequencing, and modeling with template IDs [3,12]. Classic parsers (e.g., Spell, Drain) induce templates via clustering or decision trees and assign stable IDs used to construct sequences for anomaly detection [13,14]. Parser choice and accuracy materially affect analytics quality and reliability evaluations [15]. While parsing improves structure and reduces vocabulary, it can introduce errors and maintenance overhead as systems evolve [12]. In practice, pipelines often pair robust parsers (e.g., Drain) with validation to mitigate template drift and preserve ID consistency across data splits [14,16].
Figure 1. Example of log parsing: variable tokens are replaced with “*” to extract structured event templates from raw log messages.
Sequences for modeling are constructed either by sessionizing log lines using a domain key (e.g., HDFS block ID), yielding one sequence per session, or by windowing the stream into fixed or sliding windows when no reliable session key exists [3,12,15,17,18]. In practice, sessionization preserves transaction boundaries, whereas windowing approximates context by grouping events by time or count; accordingly, HDFS is commonly sessionized by block identifiers, while BGL/Thunderbird are segmented with fixed or sliding windows [3,12,15,17,18]. We write E for the set of event templates (template IDs) and represent a sequence as X = [ e 1 , … , e L ] with e i ∈ E and L ∈ N ; each sequence carries a binary label y ∈ { 0 , 1 } indicating normal (0) or anomalous (1) [3,6].

2.2. Log-Sequence Embedding Strategies

Three common log-sequence embedding strategies are template ID-based, semantic-based, and hybrid [1]. Below, we outline each and summarize typical trade-offs.
Template ID-based (lookup): With | E | discrete IDs, a learnable embedding matrix W ∈ R | E | × d maps each event e i to v e i = W [ e i ] , allowing sequence models (e.g., CNN, LSTM, or a Transformer) to operate on compact representations and serving as a standard choice in log anomaly detection [3,6,12]. Beyond simple lookups, count-based encodings such as TF–IDF remain popular for their speed and minimal preprocessing: they can be computed at the template-ID level (template frequency within a sequence reweighted by global rarity) or at the token level within each template with aggregation back to the template; both yield a single vector per sequence, which precludes architectures requiring per-template embeddings and discards order information important for failure prediction [3,6]. A complementary approach, often called Logkey2vec, uses a trainable codebook that maps each template ID directly to an embedding vector with parameters optimized end-to-end on the target logs.
Semantic-based (textual encoders over template strings): Given a template string s ( e ) for event e ∈ E , a contextual encoder ϕ (e.g., BERT-family) maps tokenized s ( e ) to a semantic vector z e = ϕ ( s ( e ) ) , which is then composed with sequence models [3,11,12]. Compared with ID lookups, textual embeddings leverage lexical cues and can capture long-range dependencies via self-attention [11]. Pretraining objectives (e.g., masked language modeling) and fine-tuning on log corpora are commonly employed [11,12].
Hybrid (distributional + lexical weighting): Hybrid schemes combine distributional vectors for templates with lexical weighting over template terms. For example, distributional embeddings learned from template co-occurrence (template2vec-style) can be concatenated with sparse TF–IDF features to balance semantic similarity and term specificity [3,7,12]. Specific instantiations such as FastText vectors augmented with TF–IDF weights have been explored in practice [1].

2.3. Prior Work on Log-Based Anomaly Detection

Traditional approaches predate deep sequence models. Early systems leverage n-gram frequency models over template sequences, statistical projection methods such as PCA on count or invariant features, and discriminative classifiers (e.g., SVM, Random Forest) trained on handcrafted or parser-derived features [3,15,19]. Toolkits such as Loglizer provide standardized pipelines for these baselines, including feature extraction from parsed templates, PCA-based residual scoring, and SVM/RF classifiers for supervised scenarios [3,19]. These methods remain common reference points and are often reported alongside modern models for context and comparability [3,15].
Building on these baselines, deep learning introduces specialized sequence encoders. DeepLog models next-event prediction over template-ID sequences using an LSTM encoder and flags anomalies by low prediction likelihood [6]. Temporal convolutions over template sequences offer efficient local-pattern modeling and serve as competitive baselines [3]. Transformer-based methods apply self-attention over template strings or IDs; LogBERT demonstrates masked modeling and sequence scoring for anomaly detection [11].
More recent work has focused on improving robustness, leveraging advanced deep learning architectures, and exploring new paradigms like Graph Neural Networks (GNNs) and Reinforcement Learning (RL). For instance, LogEncoder explored contrastive learning objectives with a pretrained model to learn robust log-sequence representations for semi-supervised detection [20]. CSLog also utilized contrastive self-supervised representation learning to learn high-quality log-sequence representations directly from normal data, avoiding log parsing errors [21]. The GNN-based approach Logs2Graphs converts log sequences into attributed, directed, and weighted graphs, and then uses a novel GNN model for graph-level anomaly detection and explanation [22]. Furthermore, DRLLog introduced a Deep Reinforcement Learning (DRL) framework, using a Deep Q Network (DQN) agent to enable continuous online learning and adaptation to different log-sequence patterns [23].
The latest frontier in this field involves the application of large language models (LLMs) and advanced self-supervised learning. LogELECTRA applied the ELECTRA model for self-supervised anomaly detection on unstructured logs, specializing in detecting point anomalies by analyzing the semantics of a single log line [24]. LogSD proposed a novel semi-supervised self-supervised learning approach with a dual-network architecture and frequency-based masking [25]. LLM-based approaches are rapidly emerging: LogGPT was one of the early works to employ a GPT model for log anomaly detection, using a Reinforcement Learning strategy to fine-tune the model for the task [26]. LogLLM leverages LLMs (BERT for semantic vectors, Llama for classification) in a three-stage procedure, notably bypassing the need for traditional log parsers [27]. LLM-LADE proposes an LLM-based framework that not only detects anomalies but also provides explanations, using a coordinated architecture for data augmentation, PEFT, and online optimization [28]. LogLLaMA fine-tunes LLaMA2 on normal log messages and uses Reinforcement Learning to identify anomalous messages [29]. Finally, ALPHA integrates LLMs into an active learning pipeline for human-free log analysis, automating the annotation process with LLM-assisted few-shot labeling [30]. As the field has matured, systematic studies have emphasized rigorous evaluation, covering data partitioning, group leakage, and class imbalance, when comparing deep models to classical methods [2]. This progression from feature-based classifiers to sequence models and now to LLM-based methods necessitates careful accounting of preprocessing choices to avoid confounded conclusions.
Despite extensive work on log-based anomaly detection, clear conclusions about the impact of embedding strategy (template-ID, semantic, hybrid) are often difficult to draw because many comparative studies vary multiple pipeline components simultaneously. Prior results can therefore be confounded by differences in preprocessing, sequence construction, data splits, model heads, and training recipes, obscuring when simple ID embeddings suffice and when semantic information yields measurable gains. We address this gap by fixing the end-to-end pipeline in our core experiments (segmentation policy, leakage-safe splits, loss, optimization) and varying only (a) the embedding strategy and (b) the downstream head under the same set of heads (CNN, LSTM, Transformer). We report 95% bootstrap CIs, analyze window-length sensitivity and parser robustness, and assess both within-dataset performance and strict zero-shot cross-dataset transfer (train on one corpus, evaluate on another without retraining), alongside a quantitative OOV analysis.

3. Experimental Design

This section details the datasets, sequence construction, embeddings, model heads, training/evaluation protocol, and cross-dataset transfer setup used to answer RQ1 and RQ2.

3.1. Datasets

We evaluate three public corpora spanning distinct logging environments: HDFS, BGL, and Thunderbird [17,18]. A brief summary of each dataset is given below.
HDFS: The Hadoop Distributed File System logs collected from a cluster of over 200 Amazon EC2 nodes comprise 11,175,629 messages [2]. The messages are grouped by block_id to represent individual program executions, producing sessionized sequences; 16,838 blocks (approximately 2.93%) are labeled anomalous.
BGL: The Blue Gene/L supercomputer logs from Lawrence Livermore National Laboratory contain 4,747,963 messages, each manually labeled as normal or anomalous; 348,460 messages (about 7.34%) are anomalous [2,31].
Thunderbird: The Thunderbird supercomputer logs from Sandia National Laboratories include normal and abnormal messages identified by human annotators, with the full corpus exceeding 200 million messages [2,31]. For computational tractability, we use the first contiguous 10-million-message slice (about 3.55% anomalous), which preserves temporal locality.
For BGL and Thunderbird, raw log messages are parsed into templates using Drain with the same parameter settings as the reference implementation in [16]. The numbers of distinct templates extracted are 1848 (BGL) and 7382 (Thunderbird). For HDFS, we reuse the previously parsed templates reported in [15], which contain 29 distinct templates.
To assess sensitivity to the parsing method, we additionally parse BGL with Spell using the implementation and default parameters in [16]. We use the Drain parses for all main experiments to keep the preprocessing backbone fixed; Spell is used only for a targeted robustness check on BGL to quantify parser-induced variance.

3.2. Sequence Construction

We form sequences from the parsed template-ID stream using dataset-appropriate segmentation. For HDFS, messages are sessionized by block_id where each block yields one sequence in original order, reflecting a single program execution [12,15]. For BGL and Thunderbird, where no reliable session key exists, we segment the chronologically ordered stream into fixed, non-overlapping windows of 100 messages per sequence, a standard approximation in the absence of session identifiers [12,15]. Incomplete trailing windows are discarded for consistency.
To balance efficiency and coverage, HDFS sequences are capped at max length = 100; longer sessions are truncated, while shorter ones are right-padded with a dedicated <PAD> template ID. Padding tokens are ignored by the LSTM via packed sequences (Section 3.6). For BGL and Thunderbird, sequence length is fixed at 100, so no padding beyond routine mini-batch alignment is required.
Additionally, we evaluate window-length sensitivity on BGL by regenerating windowed sequences with L ∈ { 50 , 200 } and a fixed stride S = L (no overlap). All other components (parser, chronological splits, training setup, and threshold selection) are unchanged. We report PR–AUC with 95% bootstrap confidence intervals for E ∈ { E 1 , E 2 , E 3 } . All other results use the default fixed windows of L = 100 with S = L .
Sequence labels follow dataset supervision. HDFS sequences inherit the block label, while for BGL and Thunderbird, a window is labeled anomalous if it contains at least one anomalous message (otherwise normal).

3.3. Data Splits

We adopt splits of 60%/20%/20% for training, validation, and testing, respectively. For BGL and Thunderbird, we first partition raw messages chronologically by timestamp into 60%/20%/20% splits and only then construct fixed windows (100 messages) within each split. This avoids windows crossing split boundaries and prevents temporal leakage from future messages. For HDFS, we partition at the block_id (session) level into 60%/20%/20% splits using the session label to preserve anomaly prevalence across partitions. No session is split across partitions.
For cross-dataset transfer, models are trained and validated on the source dataset and then evaluated on the target test split without retraining. Sequence counts per split, including the number of anomalous sequences, are summarized in Table 1.
Table 1. Sequence-level summary after splitting the datasets.

3.4. Embedding Strategies

Given a parsed log sequence X = [ e 1 , … , e L ] of template identifiers e i ∈ V , we require a function ϕ : V → R d that maps each template to a d-dimensional vector so that the sequence becomes Z = [ z 1 , … , z L ] with z i = ϕ ( e i ) . We compare three families that are widely used in practice and keep all downstream factors constant to isolate the effect of the embedding strategy.
E1 (Template-ID (lookup) embeddings): Each template identifier receives a trainable vector via a lookup table:
ϕ E 1 ( e ) = E idx ( e ) , E ∈ R | V | × d .
We reserve indices for a padding token <PAD> and an unknown token <UNK>. The table is learned end-to-end from the training set only. This strategy is simple, fast, and effective when the template vocabulary is stable and well covered during training. Its main limitation is that unseen or rare templates at validation/test time collapse to <UNK>, providing no semantic tie to related templates. We set d = 256 .
E2 (Semantic/textual (BERT-based) embeddings): Here, the template string (event template) is encoded with a pretrained language model to obtain a fixed vector per template. Concretely, for template e with text t ( e ) , we compute
z ˜ ( e ) = MeanPool BERT ( t ( e ) ) ∈ R h , z ( e ) = W z ˜ ( e ) ∈ R d .
where h is the hidden size of the pretrained model and W ∈ R d × h is a learned linear projection (initialized randomly). We precompute z ˜ ( e ) for all training-vocabulary templates and freeze them to avoid confounding representation with sequence learning; only W is updated during training. At validation/test time, if a template not seen during training appears, we encode it on the fly with the same pretrained model (no target fitting or statistics), yielding open-vocabulary inference. This leverages subword composition and broad language statistics to connect semantically similar templates, often helpful under vocabulary shift. We use d = 256 .
E3 (Hybrid (FastText + TF–IDF) embeddings): Hybrid embeddings combine lightweight distributional word vectors with lexical salience. For template text t ( e ) , let W ( e ) be its token set, v ( w ) ∈ R p the FastText vector for token w, and  tfidf ( w , e ) its TF–IDF weight computed over all template texts. We define
z ˜ ( e ) = ∑ w ∈ W ( e ) tfidf ( w , e ) v ( w ) ∑ w ∈ W ( e ) tfidf ( w , e ) + ε ∈ R p , z ( e ) = W z ˜ ( e ) ∈ R d .
As with E2, z ˜ ( e ) is precomputed for the training vocabulary and frozen; W is learned. At validation/test time we do not refit TF–IDF on the target; unseen tokens still receive meaningful subword vectors from FastText, and if TF–IDF degenerates to all zeros, we apply a minimal safeguard by using a uniform average of the token FastText vectors. This approach is efficient, interpretable, and typically more robust than E1 under moderate template churn, while being lighter than Transformer encoders. We set p using the FastText model (e.g., 300) and d = 256 .
Efficiency considerations: The three embedding families differ in where time is spent across the full pipeline. E1 is typically the most time-efficient end-to-end because it requires no template-text encoding stage: sequences are represented by a direct d-dimensional lookup and can be trained and evaluated immediately. By contrast, E2 and E3 introduce additional work outside the sequence model itself. They must first produce a vector for each template text (with a relatively expensive pretrained encoder for E2, and a lighter TF–IDF/FastText procedure for E3), and they may additionally encode previously unseen templates at validation/test time. These costs can be reduced in practice by caching precomputed template vectors and reusing them across runs; however, caching shifts the burden toward storage and memory footprint, since the cached embedding tables must be retained and loaded (and for E2, the table is higher-dimensional, e.g.,  h = 768 , than the final d). After vectors are available, E2/E3 also incur an extra projection step per token, whereas E1 does not. Accordingly, when comparing time efficiency we consider the overall end-to-end runtime (including the time to obtain template vectors), noting that while caching can substantially reduce repeated preprocessing for E2/E3, E1 remains the most direct and typically the fastest pipeline from raw templates to model training and evaluation.

3.5. Model Heads

Given an embedded sequence Z = [ z 1 , … , z L ] , z i ∈ R d (with d = 256 for all embeddings), we compare three standard sequence-classification heads: a CNN head, an LSTM head, and a Transformer head (Figure 2). All heads output two logits per sequence (normal vs. anomalous), enabling training with the same cross-entropy loss; during evaluation, logits are converted to p ( y = 1 ) via softmax.
Figure 2. Architecture diagrams of the three model heads used for window-level log classification on embedded event sequences.
CNN head: We apply temporal one-dimensional convolutions over the time axis to detect local n-gram-like motifs, followed by global pooling, similarly to [10]:
  • Convolutions: Three parallel Conv1D layers are established with kernel widths of ( 3 , 4 , 5 ) , channel width of 128, stride of 1, and valid padding.
  • Nonlinearity and pooling: LeakyReLU (or ReLU) is applied after each convolution, then max pooling is conducted over time for each branch to obtain fixed-size vectors with length of 128.
  • Fusion and classification: The three pooled vectors are concatenated into a 384-dimensional feature, a dropout of 0.5 is applied, and then a fully connected layer R 384 → R 2 producing the two logits is applied.
  • Trainable parameters: 394 , 370 .
The CNN head is fully parallel over time and efficient for long sequences, capturing position-invariant local patterns that correlate with anomalies.
LSTM head: We use a stacked long short-term memory encoder to summarize order-sensitive context, similarly to [1]:
  • Encoder: Two LSTM layers are established with a hidden size of 128 each and a dropout of 0.1 between layers.
  • Variable-length handling: Sequences are padded to L max (we set it to 200) for batching; we compute true lengths from pad tokens and use pack_padded_sequence so padded steps are ignored by the LSTM.
  • Summary and classification: We take the final hidden state of the top layer (corresponding to the last real event per sequence), apply a dropout of 0.1 for better generalization, and then apply a fully connected layer R 128 → R 2 for the two logits.
  • Trainable parameters: 329 , 986 .
The LSTM head models temporal order and longer dependencies that may precede incidents.
Transformer head: Similarly to the architecture of the Transformer used in [1,32], we design a lightweight encoder that captures both global dependencies and relative positional context:
  • Positional encoding: Each log template embedding x i at position i is combined with a sinusoidal positional vector p i computed from sine and cosine functions of varying frequencies [33]. The resulting representation x i + p i encodes order information directly into the input.
  • Transformer encoder block: A single Transformer encoder layer is used, consisting of multi-head self-attention (8 heads) followed by a position-wise feed-forward network. Layer normalization and residual connections are applied around both sublayers to improve gradient stability.
  • Pooling and classification: the contextualized sequence representations are aggregated through global average pooling across time steps, followed by dropout ( p = 0.1 ) and a fully connected layer R 256 → R 2 that outputs the class logits.
  • Trainable parameters: 790 , 274 .
The transformer head models long-range dependencies and inter-event relations within log sequences, enabling the model to learn semantic and temporal patterns associated with anomalous behavior.
We report above the number of trainable parameters for each head. To account for trainable parameters across embeddings, the total decomposes according to P total = P head + P embed , where P head is determined solely by the chosen CNN/LSTM/Transformer head (394,370/329,986/790,274, respectively) and P embed depends on the embedding family and vocabulary size. For E1, P embed = | V | · d due to the trainable template-ID lookup table. For E2 and E3, the precomputed template vectors are frozen, and only the linear projection is learned, yielding P embed = d · h for E2 (BERT hidden size h, e.g.,  256 × 768 ) and P embed = d · p for E3 (FastText dimension p, e.g.,  256 × 300 ).

3.6. Training Protocol

We fix the output dimensionality and optimization across heads to isolate the effect of embeddings. All heads produce two logits and are trained with the same objective and optimizer configuration: cross-entropy loss (with class weights from the training split), AdamW optimizer, gradient clipping, and early model selection based on validation PR–AUC. At evaluation, we compute softmax ( · ) [ · , 1 ] and report PR–AUC (primary), AUROC, F1 at the validation-selected threshold, and precision at recall ≥ 0.9 .
The Transformer head uses the same training pipeline and hyperparameters as the CNN and LSTM heads, differing only in architecture. Its encoder block employs multi-head self-attention with dropout ( p = 0.1 ), followed by a position-wise feed-forward layer and residual normalization. Global average pooling of the contextualized sequence representations feeds into a fully connected layer R 256 → R 2 . This head generally converges more slowly than CNN and LSTM due to higher representational capacity, but benefits from stable gradients via pre-normalization and adaptive learning rate scheduling.
No method is tuned on target domains: no union vocabulary, target refitting, or target labels are used in training or selection. E2’s on-the-fly encoding is strictly an inference-time operation that uses only the test template string and the pretrained LM; it does not adapt parameters or statistics to the target. E3’s zero-vector safeguard does not introduce target statistics; it merely prevents an all-zero embedding when TF–IDF (fit on source) assigns near-zero weights to all tokens. E1 remains closed-vocabulary by construction to reflect the intended capabilities and limitations of ID-keyed approaches.

3.7. Evaluation Metrics

Our primary metric is PR–AUC (Average Precision), which is sensitive to class imbalance and reflects performance on the anomalous (positive) class. We also report AUROC for completeness.
For thresholded summaries, we compute the precision–recall curve on the validation split to select the operating threshold, and then report on the test split: (i) F 1 at the validation-selected threshold, and (ii) precision at recall ≥ 0.9 (computed by scanning thresholds). We additionally report the positive class prevalence to contextualize scores.
All metrics are computed at the sequence level on the held-out test set, using probabilities p ( y = 1 ) = softmax ( · ) [ · , 1 ] from two-logit heads. For robustness, we fix random seeds for data splits and training, and report 95% bootstrap confidence intervals for PR–AUC by resampling test sequences—i.e., resampling ( y , p ) pairs—using 1000 iterations at the sequence level.

3.8. Answering RQ1 (In-Domain Comparison)

RQ1 asks which log-sequence embedding strategy (template-ID, semantic/textual, hybrid) yields the best anomaly-detection performance when all other factors are held constant? We answer this through a controlled, in-domain comparison on each dataset separately.
For each dataset D ∈ { HDFS , BGL , Thunderbird } , we train all 3 × 3 combinations of embeddings E ∈ { E 1 ( ID ) , E 2 ( BERT ) , E 3 ( Hybrid ) } and heads H ∈ { CNN , LSTM , Transformer } on the same train/validation/test split as constructed for D. Sequence construction follows Section 3.2; the vocabulary is built from the training split only. All runs use the shared protocol (Section 3.6): two-logit cross-entropy with class weights from the training split, AdamW, gradient clipping, batch size of 128, 10 epochs, and model selection by validating PR–AUC. All embeddings output d = 256 . For E2/E3, template tables are precomputed on the training vocabulary and frozen (in-domain OOV is rare; if it occurs, E1 maps to UNK, E2 encodes on the fly, and E3 applies its zero-vector safeguard as specified in Section 3.4).
To quantify uncertainty and ensure that observed differences are statistically meaningful, all reported metrics include 95% confidence intervals estimated via nonparametric bootstrapping ( 10 3 resamples at the sequence level). Bootstrapping is applied to the held-out test predictions to capture variability in PR–AUC, AUROC, and F1 without retraining models.
For each dataset, we present: (i) a table of test metrics with PR–AUC (primary), AUROC, F 1 at the validation-selected threshold, precision at recall ≥ 0.9 , and the inferred threshold; (ii) a bar plot of PR–AUC grouped by embedding with separate bars for CNN, LSTM, and Transformer.

3.9. Answering RQ2 (Cross-Dataset Generalization)

RQ2 asks whether the RQ1 findings generalize across datasets, i.e., how well models trained on one dataset transfer to another without retraining?
We evaluate strict zero-shot transfer. RQ2 is intentionally a strict zero-shot stress test: we do not refit on the target (no target tuning, recalibration, or statistics), and we evaluate transfer under this fixed protocol. For each embedding–head pair ( E , H ) , we train on a source dataset S ∈ { HDFS , BGL , Thunderbird } using the in-domain setup (Section 3.2, Section 3.3, Section 3.4, Section 3.5 and Section 3.6), select the best checkpoint by validating PR–AUC on S, and then test the frozen model on a distinct target T ≠ S . Target sequences are constructed exactly as in Section 3.2; target template identifiers are mapped to the source vocabulary V S . Method behavior under OOV is preserved by construction of each embedding family: E1 is closed-vocabulary (unseen IDs → UNK); E2 is open-vocabulary at inference (previously unseen target templates are encoded on the fly from their strings by the pretrained LM; no target fitting or statistics); E3 uses TF–IDF fitted on the source corpus only (no target refit) with a minimal zero-vector safeguard (fallback to a uniform FastText average if TF–IDF degenerates). Probabilities use softmax ( · ) [ · , 1 ] ; thresholded metrics use the source validation threshold τ S ★ (no target peeking).
We present a 3 × 3 transfer matrix (as a heatmap) per ( E , H ) , where entry ( S → T ) is the test PR–AUC on T for the model trained on S. We also report the relative drop versus T’s in-domain performance using the equation
RelDrop ( S → T ) = 1 − PR - AUC S → T PR - AUC T → T ,
with lower values indicating better generalization.
All preprocessing, sequence construction, padding length, and evaluation metrics on T follow Section 3.2 and Section 3.7; only learned parameters and the vocabulary originate from S. Embedding dimensionality is fixed at d = 256 for all embedding strategies.

3.10. Vocabulary Coverage and OOV Characterization

We quantify novelty in the test data via token- and template-level out-of-vocabulary (OOV) statistics within and cross dataset. While these OOV rates are token-level proxies for shift severity (and do not exactly match the input units of E1, which operates on template IDs, or E2, which uses subword tokenization), they provide a consistent, parser-aligned measure to compare vocabulary shift within and across datasets. Let D = { train ( 60 % ) ,   val ( 20 % ) ,   test ( 20 % ) } denote the train, validation, and test splits.
Token-level OOV within dataset: For each dataset separately, we build a token vocabulary from the training split by splitting each training log message on whitespace:
V train tok = ⋃ m ∈ train Tokens ( m ) .
On the test split, the token OOV proportion within dataset is the fraction of token instances not found in V train tok :
OOV test tok = # { w ∈ Tokens ( test ) : w ∉ V train tok } # Tokens ( test ) .
Token-level OOV cross dataset: For a source dataset A and target dataset B, we build V train tok ( A ) from A’s training split and evaluate on B’s test split:
OOV A → B tok = # { w ∈ Tokens ( test B ) : w ∉ V train tok ( A ) } # Tokens ( test B ) .
Template-level OOV: We report the share of test events with OOV templates, i.e., the proportion of test events whose template string contains at least one token absent from the training token vocabulary:
OOV-templates ( events ) = # { test events with any OOV token in their template } # { test events } .
We compute template-level OOV within dataset (using V train tok of the same dataset) and cross dataset (using the source V train tok ( A ) on the target test set). Because any template whose text introduces an OOV token is, by construction, novel with respect to the training token vocabulary, such templates are new and, under E1 (ID lookups), will be mapped to UNK.

3.11. Implementation Details

All experiments are implemented in Python 3.10. using the PyTorch 2.8 framework with CUDA 12.8 support. HuggingFace Transformers are employed for E2 (BERT-based semantic embeddings), and Gensim FastText is used for E3 (Hybrid TF–IDF + FastText embeddings). The Transformer head leverages PyTorch’s nn.TransformerEncoderLayer with pre-normalization and mixed-precision training (torch.amp.autocast) to accelerate computation on GPU.
Experiments were conducted on a Lenovo Legion Pro 7 (2025) laptop running Windows 11 Home, equipped with an Intel® Core™Ultra 9 275HX processor, 32 GB RAM, an NVIDIA GeForce RTX 5070 Ti Laptop GPU (12 GB VRAM), and a 1 TB PCIe NVMe SSD. Training used a batch size of 128 and mixed-precision computation to reduce GPU memory overhead and improve throughput. All random seeds were fixed for reproducibility.

4. Results

We report sequence-level performance with PR–AUC as the primary metric and 95% CIs via nonparametric bootstrap over test sequences. AUROC, F 1 at τ val ★ (the threshold selected on the validation set), and Precision@Recall ≥ 0.9 are provided for operating-point context.

4.1. In-Domain Performance (RQ1)

Figure 3 summarizes PR–AUC (with 95% bootstrap CIs), and Table 2, Table 3 and Table 4 report full metrics. Across datasets, the PR–AUC patterns in the figure match the tabulated values.
Figure 3. In-domain performance (RQ1): PR–AUC (Average Precision) with 95% bootstrap confidence intervals.
Table 2. In-domain metrics on HDFS (sequence level).
Table 3. In-domain metrics on BGL (sequence level).
Table 4. In-domain metrics on Thunderbird (sequence level).
The results on the HDFS dataset show that all (embedding, head) combinations are near the ceiling: PR–AUC ≥ 0.996 with tight CIs. For example, E1–ID+LSTM reaches 0.999 [0.999, 0.999] and E2–BERT+Transformer 0.999 [0.999, 0.999]. AUROC and F 1 , best show the same trend (e.g., F 1 , best ≈ 0.99 ), indicating that the sessionized structure of HDFS makes the task comparatively easy for all heads and embeddings.
Performance on the BGL dataset is markedly lower and more spread out. The best PR–AUCs are in the 0.33–0.35 range (e.g., E2–BERT+CNN 0.348 [0.318, 0.377], E1–ID+Transformer 0.336 [0.307, 0.366]). E3–Hybrid degrades further, especially with LSTM (0.081 [0.073, 0.089]). These gaps persist in AUROC and F 1 , best , and precision at recall ≥ 0.9 is low for all settings (≈0.09–0.10), underscoring that BGL is the hardest in-domain dataset.
For the Thunderbird dataset, most settings perform strongly (PR–AUC ≈ 0.98 – 0.99 ) with narrow CIs, e.g., E1–ID+CNN 0.989 [0.983, 0.994] and E2–BERT+Transformer 0.991 [0.987, 0.995]. A notable exception is E3–Hybrid with CNN/LSTM (0.261 and 0.202), while E3–Hybrid+Transformer remains high (0.975 [0.968, 0.982]), suggesting that the Transformer head can rescue weaker lexical representations on this dataset.
The head sensitivity results are depicted in Figure 4. Head effects depend on both dataset and embedding. On BGL, CNN slightly leads for E1/E2, while LSTM trails and Transformer is competitive but not dominant. On Thunderbird, Transformer often edges out CNN/LSTM for E2 and E3, whereas on HDFS, all heads are statistically indistinguishable at the top due to ceiling effects.
Figure 4. Head sensitivity: PR–AUC with 95% confidence intervals for each embedding across datasets.
Overall, embeddings have minimal impact on HDFS (near the ceiling for all E1/E2/E3 across heads) and a modest but noticeable impact on the harder corpora. On BGL, E2–BERT paired with CNN achieves the best PR–AUC among our settings (Table 3), with E1 close behind and E3 lagging. On Thunderbird, E1–ID and E2–BERT are both strong across heads (Table 4), while E3–Hybrid is highly head-dependent—poor with CNN/LSTM but competitive when paired with a Transformer. In short, when the task is easy (HDFS), embeddings are tied; when it is harder (BGL), E2 tends to lead; and on Thunderbird, E1 and E2 are comparably high-performing, with E3 requiring a stronger head to keep up.
Window-length sensitivity was evaluated on the BGL dataset. Figure 5 plots PR–AUC across L ∈ { 50 , 100 , 200 } with 95% CIs. Performance typically rises from L = 50 to L = 100 , with smaller or mixed changes at L = 200 . For CNN, E2–BERT slightly outperforms E1–ID at L = 100 –200, while E3–Hybrid trails. For  LSTM, E1–ID peaks at L = 100 then softens at L = 200 , whereas E3–Hybrid improves with longer windows. For the Transformer, E1–ID benefits most from longer L; E2–BERT is strongest at L = 100 and dips at L = 200 ; and E3–Hybrid gains modestly. Because a window is labeled anomalous if any event in the window is anomalous, changing L also changes the effective class balance at the window level. As reported in Table 5, the prevalence of window-level anomalies increases with window length across all splits; for example, on the test split it rises from 7.35 % (1386/18,854) at L = 50 to 8.66 % ( 816 / 9427 ) at L = 100 and 10.20 % ( 481 / 4714 ) at L = 200 . Overall, L = 100 is a robust operating point, with  L = 200 offering marginal gains mainly for E1–ID+Transformer.
Figure 5. Window-length sensitivity on BGL: PR–AUC (Average Precision) with 95% bootstrap CIs across L ∈ { 50 , 100 , 200 } . Panels show heads (CNN, LSTM, Transformer); lines denote embeddings (E1–ID, E2–BERT, E3–Hybrid).
Table 5. Sequence counts and anomalous-sequence prevalence on BGL using non-overlapping windows of different lengths ( L ∈ { 50 , 100 , 200 } ).
Log parsing is the front-end that defines the discrete vocabulary seen by the model, shaping OOV rates, template granularity, and sequence statistics; different parsers (e.g., Drain vs. Spell) can therefore alter downstream performance independently of embeddings or heads. To test robustness, we compare Drain (our default elsewhere) to Spell at L = 100 on BGL in Figure 6. Spell yields consistently higher PR–AUC across heads, most notably for E2–BERT (CNN/LSTM/Transformer improve from ≈ 0.33 / 0.13 / 0.30 to ≈ 0.84 / 0.78 / 0.81 ). E1–ID also benefits, while E3–Hybrid remains lowest under both parsers (with smaller absolute gains). In many cases the 95% CIs do not overlap, indicating a substantial parser effect. We retain Drain for all main analyses to keep the experimental backbone fixed. Accordingly, our embedding comparisons should be interpreted as controlled, within-parser conclusions under a fixed parsing front-end.
Figure 6. Parser robustness on BGL at L = 100 : PR–AUC (Average Precision) with 95% bootstrap CIs comparing Drain and Spell.
To complement detection performance, we report practical efficiency indicators including training time per epoch and inference throughput. The efficiency results shown in Table 6 are reported for BGL at L = 100 using the default embedding size d = 256 using the Transformer head.
Table 6. Efficiency summary on BGL ( L = 100 , d = 256 ) with the Transformer head.
To assess sensitivity to model capacity and embedding dimensionality, we also conduct two small ablations on BGL ( L = 100 ) using the Transformer head with E1-ID embeddings: (i) increasing the depth of the Transformer head (from the default one layer to four layers), and (ii) varying the embedding dimension ( d ∈ { 128 , 256 , 512 } ). Table 7 summarizes the resulting performance–efficiency trade-offs.
Table 7. Capacity sensitivity on BGL ( L = 100 ) with the Transformer head and E1-ID embeddings: effect of Transformer depth (number of layers) and embedding dimension (d).

4.2. Cross-Dataset Generalization (RQ2)

Across embeddings and heads, strict zero-shot transfer is challenging. The heatmaps in Figure 7, Figure 8 and Figure 9 (top rows) show that PR–AUC frequently approaches the target prevalence, most notably for transfers into BGL and for several BGL/Thunderbird-related pairs, although some transfer directions remain clearly above prevalence. The bottom rows visualize the corresponding relative drop (RelDrop) against in-domain performance: off-diagonal cells typically show substantial drops, with the magnitude varying by dataset pair and head.
Figure 7. Cross-dataset transfer for E1–ID. Top: PR–AUC heatmaps. Bottom: relative drop. Rows = source S, columns = target T (HDFS, BGL, Thunderbird). Columns of subplots are heads (CNN, LSTM, Transformer).
Figure 8. Cross-dataset transfer for E2–BERT. Top: PR–AUC heatmaps. Bottom: relative drop. Rows = source S, columns = target T (HDFS, BGL, Thunderbird). Columns of subplots are heads (CNN, LSTM, Transformer).
Figure 9. Cross-dataset transfer for E3–Hybrid. Top: PR–AUC heatmaps. Bottom: relative drop. Rows = source S, columns = target T (HDFS, BGL, Thunderbird). Columns of subplots are heads (CNN, LSTM, Transformer).
Figure 7 shows the results of cross-dataset transfer for E1–ID. Despite its closed vocabulary, E1 yields PR–AUC above the target prevalence in several transfers, whereas transfer into BGL is often close to its target prevalence. This pattern is consistent with the idea that additional structure in HDFS (via sessionization by block_id) can provide transferable cues (e.g., motif length or boundary patterns), partially mitigating the closed-vocabulary limitation even when many target templates map to <UNK>. Conversely, transfers into highly drift-prone windowed targets (notably BGL) exhibit heavier lexical shift and weaker structural regularities, pushing E1 toward prevalence-like behavior.
The results of E2–BERT for cross-dataset transfer are given in Figure 8. Open-vocabulary textual embeddings provide improvements over E1 in several transfer settings, but the gains are uneven across heads and source→target directions. We observe pockets of lighter cells (higher PR–AUC, lower RelDrop) relative to E1, yet some transfers remain close to target prevalence. This indicates that generic LM semantics help when template text retains transferable cues; otherwise, domain shift in technical tokens (paths, IDs, hex) limits benefits.
Figure 9 provides the results of cross-dataset transfer for E3–Hybrid (TF–IDF+FastText). Similar to E1 and E2, E3 shows mixed behavior under strict zero-shot transfer. Because IDF is fit on the source templates only (no target refit), many target tokens can receive weak or uniform weights, reducing contrast. Consequently, performance varies by direction and head: E3 can outperform E1/E2 in some transfers (e.g., HDFS→Thunderbird), but it often matches or trails them elsewhere.
Columns within each of Figure 7, Figure 8 and Figure 9 (CNN/LSTM/Transformer) reveal that transfer depends strongly on both the head and the embedding. The head that wins in-domain is not reliably best off-domain: in several transfer directions, CNN shows smaller RelDrop, whereas Transformer can exhibit larger RelDrop (suggesting stronger source-specific fitting) or, in a few cases, hold up better when the embedding provides stronger lexical alignment.
To summarize, (i) strict zero-shot transfer is challenging and highly source–target dependent; (ii) transfers involving HDFS can be stronger in some settings, consistent with the additional structure introduced by sessionization; (iii) E2 offers improvements over E1 in several cases but remains uneven across heads and transfer directions; (iv) E3 is mixed under source-only IDF, showing strong gains in some directions but inconsistent behavior in others; and (v) head choice materially affects robustness. Overall, these results support the hypothesis that vocabulary shift and cross-domain lexical mismatch dominate transfer difficulty, while structural cues (as in HDFS) can partially rescue performance in favorable transfer settings.
To further disentangle ranking robustness from operating-point (threshold) effects under strict zero-shot transfer, Figure 10 provides illustrative precision–recall (PR) curves on the target test set for three representative transfers (one per embedding). PR–AUC summarizes performance independent of any single threshold, while the marked point corresponds to applying the source-selected threshold τ source ⁢ on the target. This visualization helps clarify whether a degradation in transfer is driven mainly by poor ranking (low PR–AUC) or by a threshold mismatch on the target (reasonable PR–AUC but weak precision/recall at τ source ⁢ ), without changing the strict evaluation protocol.
Figure 10. Sample precision–recall (PR) curves for RQ2 strict transfer (one per embedding). Each panel shows a representative transfer cell with the operating point induced by the source-selected threshold τ source ⁢ marked on the curve (selected on the source validation set and applied unchanged on the target test set).

4.3. Vocabulary Shift and OOV Impact

Table 8 provides within-dataset OOV. It quantifies novelty on each test split relative to its own training token vocabulary. HDFS exhibits effectively zero shift (Token OOV = 3.74   ×   10 − 6 % , OOV–templ = 3.13   ×   10 − 6 % ), which is consistent with its near-ceiling in-domain PR–AUC across all embeddings and heads (Figure 3, Table 2, Table 3 and Table 4). Thunderbird shows modest shift (Token OOV 0.373 % , OOV–templ 2.076 % ) and correspondingly high PR–AUC for E1/E2 (Table 4). By contrast, BGL has substantial novelty (Token OOV 39.693 % , OOV–templ 75.749 % ) and also the lowest in-domain PR–AUCs (Table 3), indicating that even within-dataset generalization is sensitive to vocabulary churn introduced by parsing and message variability.
Table 8. Within-dataset OOV using each dataset’s training token vocabulary (Drain parses).
Table 9 gives the cross-dataset OOV. It shows that most source→target pairs face extreme novelty (OOV–templ ≈ 100 % , Token OOV ∼ 40 – 96 % ). Consistent with the heatmaps (Figure 7, Figure 8 and Figure 9), PR–AUC often collapses toward the positive prevalence across all embeddings. Although text-based embeddings (E2–BERT, E3–Hybrid) are intended to be more tolerant in principle, our empirical results do not show a uniform advantage in zero-shot transfer: under severe shift, the performance gaps between E1/E2/E3 are small or inconsistent. In some pairs, E1–ID matches or exceeds E2/E3, likely because models exploit non-content signals (e.g., padding/length patterns).
Table 9. Cross–dataset OOV where the source training token vocabulary (A) is applied to the target test split (B).

5. Discussion and Threats to Validity

5.1. Discussion

RQ1 (in-domain): Across HDFS, BGL, and Thunderbird, no single embedding dominates universally; the effect of embedding depends on dataset difficulty and head. On HDFS, all embeddings (E1–ID, E2–BERT, E3–Hybrid) reach near-ceiling PR–AUC across heads (Figure 3; Table 2). BGL is harder: E2–BERT is competitive with CNN and Transformer but drops sharply with LSTM; E1–ID is generally close behind; and E3–Hybrid is lowest overall (Table 3). On Thunderbird, E3–Hybrid is weak with CNN/LSTM but strong with Transformer, while E1–ID and E2–BERT are consistently high across heads (Table 4). Overall for RQ1, embedding choice matters primarily on the harder dataset (BGL) and in pairing with the head, whereas on easier data (HDFS; much of Thunderbird) all embeddings are near the ceiling, and head choice plays a secondary role.
RQ2 (cross-dataset): Zero-shot transfer is challenging. Across {HDFS, BGL, and Thunderbird}, PR–AUC on targets often drops substantially relative to in-domain baselines (Figure 7, Figure 8 and Figure 9). The drop is asymmetric ( S → T ≠ T → S ) and varies by both embedding and head. E1–ID exhibits frequent degradations—often approaching prevalence-level PR–AUC on difficult routes—consistent with its closed-vocabulary nature under distribution shift; nonetheless, some routes into HDFS show higher transfer than into BGL. E2–BERT and E3–Hybrid yield mixed improvements: they mitigate drops on some S → T pairs, but do not universally dominate E1 and can still fail on hostile shifts. Among heads, robustness varies by transfer direction: the Transformer is often competitive, whereas the LSTM exhibits the largest variability (e.g., strong in-domain but fragile under transfer on certain routes). Overall, RQ2 is answered in the negative: in-domain winners do not reliably generalize across datasets without adaptation; embedding choice and head both matter, and transfer success depends heavily on the specific source–target pairing (see also Section 4.3 for vocabulary-shift analysis).
Parsing impact: Parser choice can be a first-order factor in log anomaly detection because it determines the template inventory and tokenization that all embeddings consume, thereby shaping OOV rates, template granularity, and sequence statistics. On BGL (Figure 6), switching from Drain to Spell at L = 100 yields substantial PR–AUC gains across heads, with the largest boosts for E2–BERT and clear improvements for E1–ID; E3–Hybrid remains lowest but still benefits. Accordingly, our embedding comparisons are best interpreted as controlled, within-parser conclusions under a fixed parsing front-end. Beyond detection performance, parser choice also affects end-to-end efficiency: it influences (i) the offline parsing stage that converts raw lines into templates and (ii) downstream training/inference via the induced vocabulary size and template granularity, which in turn affect the one-time construction cost of embedding tables and the overall efficiency.
Efficiency impact: The results in Table 6 highlight that runtime differences across embeddings on BGL with the Transformer head are relatively modest in the measured training/inference loop. E1–ID delivers the fastest inference throughput (90,786 windows/s) with a comparable training cost (1.384 s/epoch), reflecting its direct lookup pipeline without per-token projection. E2–BERT is slightly slower in both training (1.420 s/epoch) and inference (76,121 windows/s), consistent with the additional projection step applied after obtaining template vectors. E3–Hybrid shows the fastest training loop (1.312 s/epoch) while maintaining high throughput (87,107 windows/s), indicating that once template vectors are available, its in-loop overhead is small. Importantly, these timings capture only the sequence-model runtime under fixed hardware and implementation; they do not include the end-to-end embedding construction costs that differ by family. As explained in Section 3.4, E1 is typically the most time-efficient end-to-end because it avoids template-text encoding altogether, whereas E2 and E3 require constructing (and potentially encoding unseen) template vectors outside the model loop. Caching can amortize this preprocessing across runs, but shifts cost toward storage and memory footprint (and for E2, higher-dimensional cached tables before projection). Overall, per-epoch and per-window runtime are broadly similar once vectors are available, but the practical deployment trade-off favors E1 for its simplicity and because it has the lowest end-to-end overhead, while E2/E3 may incur additional upfront or occasional embedding costs.
Capacity sensitivity: Table 7 shows a clear capacity–efficiency trade-off on BGL when scaling the Transformer head and the E1-ID embedding dimension. Increasing depth from one to four layers at d = 256 substantially increases computation cost (training time rises from 1.384 to 4.139 s/epoch, and throughput drops from 90,786 to 28,258 windows/s), indicating that depth is the dominant driver of runtime in this setting. Varying d at a fixed one-layer head yields a smoother scaling curve: reducing it to d = 128 improves both training (0.924 s/epoch) and inference (133,843 windows/s), while increasing it to d = 512 incurs a marked slowdown (3.215 s/epoch; 32,691 windows/s). Overall, these results suggest that for BGL, the most practical efficiency gains come from keeping the head shallow and selecting a moderate embedding size (or even d = 128 when throughput is critical), whereas deeper/wider configurations quickly reduce throughput and may be justified only when the additional capacity is needed for accuracy.
Vocabulary shift impact: Vocabulary shift (measured based on token and template out-of-vocabulary (OOV) rates) tracks the difficulty the models face. Within datasets (Table 8), HDFS exhibits essentially zero OOV (Token < 10 − 3 % , Templ < 10 − 3 % ), aligning with near-ceiling PR–AUC across embeddings and heads. Thunderbird shows low token OOV ( ≈ 0.37 % ) and modest template OOV ( ≈ 2.08 % ), consistent with strong in-domain performance. In contrast, BGL has very high OOV (Token ≈ 40 % , Templ ≈ 76 % ), and is the hardest in-domain benchmark, where embedding–head differences become most visible. Cross datasets (Table 9), OOV rates are extreme (often Token > 90 % and Template ≈ 100 % ). This corresponds to large relative drops in transfer PR–AUC (Figure 7, Figure 8 and Figure 9). Closed-vocabulary E1–ID is especially vulnerable because unseen templates collapse to <UNK>; open-vocabulary encoders (E2–BERT, E3–Hybrid) are more tolerant in principle, but still degrade substantially at the observed OOV levels, likely because many parser templates contain tokens with weak semantic signals (e.g., hexadecimal IDs, hashes, memory addresses, file paths, IPs, numeric counters). Such tokens dominate the text surface yet convey little reusable meaning across systems, limiting the advantage of subword or distributional encoders even when they can embed previously unseen strings. Residual non-trivial PR–AUC in some high-OOV transfers likely reflects sequence-level priors (e.g., anomaly prevalence, session/window structure, PAD masking) rather than robust semantic generalization. Overall, the evidence indicates that vocabulary shift is a primary driver of cross-dataset failures, reinforcing the need to report OOV statistics alongside transfer results.
Implications for deployment: Our results suggest several practical guidelines. (i) Prioritize in-domain models when feasible: All embeddings reach near-ceiling PR–AUC on HDFS, but cross-dataset transfer degrades sharply, especially under high OOV and parser mismatch. (ii) Standardize parsing: The choice of parser materially shifts outcomes; pick one pipeline (parameters + version) and keep it fixed across train/serve, or re-parse historical logs to match production. (iii) Monitor vocabulary drift: Track token and template OOV rates in production; rising OOV is an actionable early-warning signal to refresh the model or parser. (iv) Choose head/embedding by workload: CNN and Transformer pair well with E1 and E2 in practice; E3 can be strong with Transformer but is fragile with CNN/LSTM on harder corpora. (v) Harden text for open-vocabulary encoders: Normalize or mask low-semantic tokens (hex IDs, hashes, paths, IPs) before embedding to preserve the benefits of E2/E3. (vi) Plan for adaptation: For new targets, expect zero-shot to be brittle unless OOV is low; budget for periodic fine-tuning or light adaptation (e.g., re-embedding new templates for E2/E3), and re-validation after parser or data shifts.

5.2. Threats to Validity

Internal validity: We avoided temporal leakage by (i) performing chronological splits before windowing for BGL/Thunderbird and (ii) splitting HDFS at the session level without crossing partitions. However, risks remain: padding and max-length choices can create artifacts (e.g., PAD/non-PAD boundaries that some heads may exploit); threshold selection uses the validation split (we therefore use PR–AUC as the primary metric and add 95% bootstrap CIs, noting that bootstrap reflects test resampling, not retraining variance); fixed hyperparameters limit overfitting but may under-tune some models; OOV accounting depends on parser/tokenization and could be biased by implementation quirks; and label noise in public corpora (especially message-level labels) may affect both learning and evaluation.
Construct validity: We target sequence-level anomaly detection from parsed logs. Our constructs (fixed windows for BGL/Thunderbird, sessionization for HDFS, template-based representations, and PR–AUC as the primary metric) approximate but do not perfectly match all operational use cases. Windows can merge/split incidents, and sequence labels (anomalous if any message is anomalous) may not reflect operator alerting policies. Template text often contains low-semantic tokens (IDs, hashes, hex), potentially muting the benefit of text-based embeddings. While AUROC, F1, and precision at recall ≥ 0.9 complement PR–AUC, stakeholders may value other objectives (e.g., latency, false-positive cost). Our cross-dataset protocol is strict zero-shot, measuring robustness without the lightweight adaptation many deployments would apply.
External validity: We study three popular corpora (HDFS, BGL, Thunderbird), yet they reflect specific infrastructures, time periods, and logging practices. Results may differ for other systems, newer stacks, or different anomaly prevalence. For Thunderbird we analyze a contiguous 10M-message slice for tractability; other slices may differ. We compare two parsers (Drain, Spell); other parsers or settings could alter OOV structure and downstream accuracy. Likewise, the embedding families (ID, BERT-based text, FastText+TF–IDF) and heads (CNN/LSTM/Transformer) are representative, not exhaustive, domain-tuned LMs, structure-aware parsing, or self-supervised pretraining may generalize differently.

6. Conclusions and Future Work

This paper presented a controlled study of sequence-level log anomaly detection across three public corpora (HDFS, BGL, Thunderbird), disentangling the effects of embeddings (E1–ID, E2–BERT, E3–Hybrid) and heads (CNN/LSTM/Transformer) under a common training/evaluation protocol and a fixed parsing backbone.
Within dataset, on HDFS and much of Thunderbird, all embeddings paired with standard heads achieve near-ceiling PR–AUC, suggesting that once the template inventory is well covered, architectural choice plays a secondary role. On the harder BGL corpus, embedding–head interactions matter: text-based E2–BERT is competitive with CNN/Transformer but fragile with LSTM; E3–Hybrid lags with CNN/LSTM yet improves with Transformer. Overall, the best configuration is dataset-dependent rather than universally fixed.
Cross dataset, strict zero-shot transfer reveals substantial degradation when moving between logging environments, with the magnitude of drop closely tied to vocabulary shift (OOV) measured from training to test. While open-vocabulary encoders can mitigate some shifts, very high OOV rates still erode performance, and closed-vocabulary ID embeddings predictably struggle when unseen templates dominate.
A targeted comparison also shows that parser choice can be a first-order factor for downstream accuracy and OOV structure; accordingly, our embedding-centric findings should be interpreted as controlled, within-parser conclusions under a fixed parsing front-end.
From a practical standpoint, for stable domains with a largely covered template inventory and tight operational constraints, E1–ID remains a strong, simple baseline. In settings with expected churn or cross-domain deployment, text-aware encoders and heads that capture longer context are preferable, but their benefits depend on the upstream parsing/normalization pipeline and may require lightweight adaptation when drift is high.
For future work, we highlight three priorities: (i) parser-aware modeling that learns from raw logs (or uses robust subword tokenization) to reduce brittle template IDs and lower effective OOV; (ii) lightweight adaptation (calibration, threshold transfer, feature-space alignment, or few-shot fine-tuning) to bridge source–target gaps without full retraining; and (iii) self-supervised pretraining on large unlabeled log corpora (e.g., masked event modeling, contrastive learning) to strengthen sequence semantics and improve zero-shot robustness.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Data Availability Statement

All datasets used in this study (HDFS, BGL, and Thunderbird) are publicly available at https://github.com/logpai/loghub (accessed on 1 November 2025) and are widely used in the log-analysis literature. We follow publicly documented preprocessing and sequence-construction steps; any additional derived artifacts are available from the author upon reasonable request.

Conflicts of Interest

The author declares no conflicts of interest.

References

  1. Hadadi, F.; Dawes, J.H.; Shin, D.; Bianculli, D.; Briand, L.C. Systematic Evaluation of Deep Learning Models for Log-based Failure Prediction. Empir. Softw. Eng. 2023, 29, 105. [Google Scholar] [CrossRef] [Scilit]
  2. Le, V.H.; Zhang, H. Log-based anomaly detection with deep learning: How far are we? In Proceedings of the 44th International Conference on Software Engineering, New York, NY, USA, 8–20 May 2022; ICSE ’22. pp. 1356–1367. [Google Scholar] [CrossRef] [Scilit]
  3. He, S.; He, P.; Chen, Z.; Yang, T.; Su, Y.; Lyu, M.R. A Survey on Automated Log Analysis for Reliability Engineering. ACM Comput. Surv. 2021, 54, 1–37. [Google Scholar] [CrossRef] [Scilit]
  4. Carvalho, T.P.; Soares, F.A.A.M.N.; Vita, R.; da Piedade, F.R.; Basto, J.P.; Alcalá, S.G.S. A systematic literature review of machine learning methods applied to predictive maintenance. Comput. Ind. Eng. 2019, 137, 106024. [Google Scholar] [CrossRef] [Scilit]
  5. Khan, Z.A.; Shin, D.; Bianculli, D.; Briand, L.C. Impact of log parsing on deep learning-based anomaly detection. Empir. Softw. Eng. 2023, 29, 139. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  6. Du, M.; Li, F.; Zheng, G.; Srikumar, V. DeepLog: Anomaly Detection and Diagnosis from System Logs through Deep Learning. In Proceedings of the 2017 ACM SIGSAC Conference on Computer and Communications Security, New York, NY, USA, 30 October–3 November 2017; CCS ’17. pp. 1285–1298. [Google Scholar] [CrossRef] [Scilit]
  7. Meng, W.; Liu, Y.; Zhu, Y.; Zhang, S.; Pei, D.; Liu, Y.; Chen, Y.; Zhang, R.; Tao, S.; Sun, P.; et al. LogAnomaly: Unsupervised Detection of Sequential and Quantitative Anomalies in Unstructured Logs. In Proceedings of the Twenty-Eighth International Joint Conference on Artificial Intelligence, IJCAI-19. International Joint Conferences on Artificial Intelligence Organization, Macao, China, 10–16 August 2019; pp. 4739–4745. [Google Scholar] [CrossRef] [Scilit]
  8. Zhang, X.; Xu, Y.; Lin, Q.; Qiao, B.; Zhang, H.; Dang, Y.; Xie, C.; Yang, X.; Cheng, Q.; Li, Z.; et al. Robust log-based anomaly detection on unstable log data. In Proceedings of the 2019 27th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering, New York, NY, USA, 26–30 August 2019; ESEC/FSE 2019. pp. 807–817. [Google Scholar] [CrossRef] [Scilit]
  9. Yang, L.; Chen, J.; Wang, Z.; Wang, W.; Jiang, J.; Dong, X.; Zhang, W. Semi-supervised Log-based Anomaly Detection via Probabilistic Label Estimation. In Proceedings of the 43rd International Conference on Software Engineering; IEEE Press: Piscataway, NJ, USA, 2021; ICSE ’21; pp. 1448–1460. [Google Scholar] [CrossRef] [Scilit]
  10. Lu, S.; Wei, X.; Li, Y.; Wang, L. Detecting Anomaly in Big Data System Logs Using Convolutional Neural Network. In Proceedings of the 2018 IEEE 16th Intl Conf on Dependable, Autonomic and Secure Computing, 16th Intl Conf on Pervasive Intelligence and Computing, 4th Intl Conf on Big Data Intelligence and Computing and Cyber Science and Technology Congress(DASC/PiCom/DataCom/CyberSciTech), Athens, Greece, 12–15 August 2018; pp. 151–158. [Google Scholar] [CrossRef] [Scilit]
  11. Guo, H.; Yuan, S.; Wu, X. LogBERT: Log Anomaly Detection via BERT. In Proceedings of the 2021 International Joint Conference on Neural Networks (IJCNN), Shenzhen, China, 18–22 July 2021; pp. 1–8. [Google Scholar] [CrossRef] [Scilit]
  12. Zhang, T.; Qiu, H.; Castellano, G.; Rifai, M.; Chen, C.S.; Pianese, F. System Log Parsing: A Survey. IEEE Trans. Knowl. Data Eng. 2023, 35, 8596–8614. [Google Scholar] [CrossRef] [Scilit]
  13. Makanju, A.A.; Zincir-Heywood, A.N.; Milios, E.E. Clustering event logs using iterative partitioning. In Proceedings of the 15th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, New York, NY, USA, 28 June–1 July 2009; KDD ’09. pp. 1255–1264. [Google Scholar] [CrossRef] [Scilit]
  14. He, P.; Zhu, J.; Zheng, Z.; Lyu, M.R. Drain: An Online Log Parsing Approach with Fixed Depth Tree. In Proceedings of the 2017 IEEE International Conference on Web Services (ICWS), Honolulu, HI, USA, 25–30 June 2017; pp. 33–40. [Google Scholar] [CrossRef] [Scilit]
  15. He, S.; Zhu, J.; He, P.; Lyu, M.R. Experience Report: System Log Analysis for Anomaly Detection. In Proceedings of the 2016 IEEE 27th International Symposium on Software Reliability Engineering (ISSRE), Ottawa, ON, Canada, 23–27 October 2016; pp. 207–218. [Google Scholar] [CrossRef] [Scilit]
  16. LogPAI. Logparser: A Machine Learning Toolkit for Automated Log Parsing. GitHub Repository; Implements Drain, Spell, IPLoM, and Other Parsers. 2019. Available online: https://github.com/logpai/logparser (accessed on 1 November 2025).
  17. Zhu, J.; He, S.; He, P.; Liu, J.; Lyu, M.R. Loghub: A Large Collection of System Log Datasets for AI-driven Log Analytics. In Proceedings of the IEEE International Symposium on Software Reliability Engineering (ISSRE), Florence, Italy, 9–12 October 2023. [Google Scholar]
  18. Jiang, Z.; Liu, J.; Huang, J.; Li, Y.; Huo, Y.; Gu, J.; Chen, Z.; Zhu, J.; Lyu, M.R. A Large-scale Evaluation for Log Parsing Techniques: How Far are We? In Proceedings of the ACM SIGSOFT International Symposium on Software Testing and Analysis (ISSTA), Vienna, Austria, 16–20 September 2024. [Google Scholar]
  19. LogPAI. Loglizer: A Machine Learning Toolkit for Log-based Anomaly Detection. GitHub Repository; Classic and Deep-learning Baselines for Log-Based Anomaly Detection. 2019. Available online: https://github.com/logpai/loglizer (accessed on 1 November 2025).
  20. Qi, J.; Luan, Z.; Huang, S.; Fung, C.; Yang, H.; Li, H.; Zhu, D.; Qian, D. LogEncoder: Log-Based Contrastive Representation Learning for Anomaly Detection. IEEE Trans. Netw. Serv. Manag. 2023, 20, 1378–1391. [Google Scholar] [CrossRef] [Scilit]
  21. Yan, S.; Wang, S.; Chen, Z.; Jiang, X.; Cao, X. CSLog: Anomaly Detection for Syslog Based on Contrastive Self-Supervised Representation Learning. In Proceedings of the 2023 24st Asia-Pacific Network Operations and Management Symposium (APNOMS), Sejong, Republic of Korea, 6–8 September 2023; pp. 165–170. [Google Scholar]
  22. Li, Z.; Shi, J.; Van Leeuwen, M. Graph Neural Networks based Log Anomaly Detection and Explanation. In Proceedings of the 2024 IEEE/ACM 46th International Conference on Software Engineering: Companion Proceedings, New York, NY, USA, 14–20 April 2024; ICSE-Companion ’24. pp. 306–307. [Google Scholar] [CrossRef] [Scilit]
  23. Zhou, J.; Gao, Y.; Zhu, Y.; Yu, X.; Yang, Y.; Tan, C.; Xiang, J. DRLLog: Deep Reinforcement Learning for Online Log Anomaly Detection. IEEE Trans. Netw. Serv. Manag. 2025, 22, 2382–2395. [Google Scholar] [CrossRef] [Scilit]
  24. Yamanaka, Y.; Takahashi, T.; Minami, T.; Nakajima, Y. LogELECTRA: Self-supervised anomaly detection for unstructured logs. arXiv 2024, arXiv:2402.10397. [Google Scholar]
  25. Xie, Y.; Zhang, H.; Babar, M.A. LogSD: Detecting Anomalies from System Logs through Self-Supervised Learning and Frequency-Based Masking. Proc. ACM Softw. Eng. 2024, 1, 2098–2120. [Google Scholar] [CrossRef] [Scilit]
  26. Han, X.; Yuan, S.; Trabelsi, M. LogGPT: Log Anomaly Detection via GPT. In Proceedings of the 2023 IEEE International Conference on Big Data (BigData), Sorrento, Italy, 15–18 December 2023; pp. 1117–1122. [Google Scholar] [CrossRef] [Scilit]
  27. Guan, W.; Cao, J.; Qian, S.; Gao, J.; Ouyang, C. Logllm: Log-based anomaly detection using large language models. arXiv 2025, arXiv:2411.08561. [Google Scholar]
  28. Zhang, Z.; Li, S.; Zhang, L.; Ye, J.; Hu, C.; Yan, L. LLM-LADE: Large language model-based log anomaly detection with explanation. Knowl.-Based Syst. 2025, 326, 114064. [Google Scholar] [CrossRef] [Scilit]
  29. Yang, Z.; Harris, I.G. LogLLaMA: Transformer-based log anomaly detection with LLaMA. arXiv 2025, arXiv:2503.14849. [Google Scholar]
  30. Luo, X.; Jha, S.M.N.; Sinha, A.; Li, Z.; Liu, Y. ALPHA: LLM-Enabled Active Learning for Human-Free Network Anomaly Detection. arXiv 2025, arXiv:2509.05936. [Google Scholar]
  31. Oliner, A.; Stearley, J. What Supercomputers Say: A Study of Five System Logs. In Proceedings of the 37th Annual IEEE/IFIP International Conference on Dependable Systems and Networks (DSN’07), Edinburgh, UK, 25–28 June 2007; pp. 575–584. [Google Scholar] [CrossRef] [Scilit]
  32. Le, V.H.; Zhang, H. Log-based anomaly detection without log parsing. In Proceedings of the 36th IEEE/ACM International Conference on Automated Software Engineering; IEEE Press: Piscataway, NJ, USA, 2022; ASE ’21; pp. 492–504. [Google Scholar] [CrossRef] [Scilit]
  33. Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, L.; Polosukhin, I. Attention is all you need. In Proceedings of the 31st International Conference on Neural Information Processing Systems, Red Hook, NY, USA, 4–9 December 2017; NIPS’17. pp. 6000–6010. [Google Scholar]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.