<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>PeFAD: A Parameter-Efficient Federated Framework for Time Series Anomaly Detection</title></titleStmt>
			<publicationStmt>
				<publisher>IEEE KDD</publisher>
				<date>08/26/2024</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10575717</idno>
					<idno type="doi"></idno>
					
					<author>X Xu</author><author>H Miao</author><author>S Wang</author><author>Philip S Yu</author><author>J Wang</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[With the proliferation of mobile sensing techniques, huge amounts of time series data are generated and accumulated in various domains, fueling plenty of real-world applications. In this setting, time series anomaly detection is practically important. It endeavors to identify deviant samples from the normal sample distribution in time series. Existing approaches generally assume that all the time series is available at a central location. However, we are witnessing the decentralized collection of time series due to the deployment of various edge devices. To bridge the gap between the decentralized time series data and the centralized anomaly detection algorithms, we propose a Parameter-efficient Federated Anomaly Detection framework named PeFAD with the increasing privacy concerns. PeFAD for the first time employs the pre-trained language model (PLM) as the body of the client's local model, which can benefit from its cross-modality knowledge transfer capability. To reduce the communication overhead and local model adaptation cost, we propose a parameter-efficient federated training module such that clients only need to fine-tune small-scale parameters and transmit them to the server for update. PeFAD utilizes a novel anomaly-driven mask selection strategy to mitigate the impact of neglected anomalies during training. A knowledge distillation operation on a synthetic privacy-preserving dataset that is shared by all the clients is also proposed to address the data heterogeneity issue across clients. We conduct extensive evaluations on four real datasets, where PeFAD outperforms existing state-of-the-art baselines by up to 28.74%.]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><p>KEYWORDS Time Series Anomaly Detection; Pre-trained Language Model; Federated Learning;</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">INTRODUCTION</head><p>With the increase of various sensors and mobile devices, massive volumes of time series data are being collected in a decentralized fashion, enabling various time series applications <ref type="bibr">[18,</ref><ref type="bibr">19,</ref><ref type="bibr">31,</ref><ref type="bibr">34]</ref>, such as fault diagnosis <ref type="bibr">[7]</ref> and fraud detection <ref type="bibr">[2]</ref>. A fundamental aspect of these applications is time series anomaly detection <ref type="bibr">[38]</ref>, as illustrated in Figure <ref type="figure">1</ref>, which aims to find unusual observations or trends in a time series that may indicate errors, or other abnormal situations requiring further investigations. Due to its significance, substantial research has been devoted to inventing effective time series anomaly detection models <ref type="bibr">[2,</ref><ref type="bibr">38]</ref>, including approaches based on traditional statistics <ref type="bibr">[11,</ref><ref type="bibr">29]</ref> and neural networks <ref type="bibr">[38]</ref>. Due to the difficulty in annotating anomalies, unsupervised methods become mainstream approaches, which can primarily be categorized into reconstruction-based <ref type="bibr">[38,</ref><ref type="bibr">45]</ref> and prediction-based <ref type="bibr">[33,</ref><ref type="bibr">42]</ref> approaches. The former identifies anomalies based on the reconstruction errors while the latter identifies anomalies based on the prediction errors. In real-world scenarios, time series data is often generated by edge devices (e.g., sensors) that are distributed at different locations. However, most existing time series anomaly detection models generally require centralized training data, making them less effective in the decentralized scenarios. Due to the increasing concern on privacy protection, the data providers may not be willing to disclose their data. For instance, the credit agency Equifax experienced a data breach <ref type="bibr">[46]</ref> that exposed social security numbers and other sensitive data, significantly impacting individuals' financial security. Therefore, decentralized time series anomaly detection has become a critical issue to enable privacy protection <ref type="bibr">[16]</ref> and ensure data access restrictions <ref type="bibr">[17]</ref>.</p><p>Recently, Federated Learning (FL) has provided a solution for training a model with decentralized data distributed on multiple clients <ref type="bibr">[16,</ref><ref type="bibr">39]</ref>. FL is a machine learning setting where many clients collaboratively train a model under the orchestration of a central server while keeping data decentralized. In this study, we aim to develop a novel FL framework for unsupervised time series anomaly detection for bridging the gap between the decentralized data processing and the unsupervised time series anomaly detection.</p><p>However, developing a federated learning-based time series anomaly detection model is non-trivial due to the following three challenges. First, it is challenging to deal with the data scarcity issue in the context of federated learning. Due to the limitation of data collection mechanisms (e.g., low sampling rates) and data privacy concerns, client-side local data can be very sparse, especially for the minority anomalous data. The performance of existing methods that rely on sufficient training data may degrade remarkably in the scenario of decentralized training data. Second, existing unsupervised methods <ref type="bibr">[38,</ref><ref type="bibr">45]</ref> often overlook the presence of anomalies during training. This may significantly disrupt the training process of both prediction and reconstruction-based methods, affecting their ability to accurately identify the anomalies <ref type="bibr">[37]</ref>. For instance, in reconstruction-based methods, if the masked time series fragments do not cover anomalous time points in training, the learned time series reconstruction model will be less sensitive to the anomalies <ref type="bibr">[35]</ref>. Third, it is also difficult to obtain a global model that generalizes well across all clients due to the heterogeneity of the local data. The time series that are collected across different edge devices are typically heterogeneous and non-identical distributed <ref type="bibr">[41]</ref>. It is non-trivial for a FL model to achieve an optimal global model by simply aggregating local models due to the distribution drift across different local time series datasets.</p><p>To address the above challenges, this paper proposes a Parameterefficient Federated time series Anomaly Detection framework named PeFAD. PeFAD adopts a horizontal federated learning schema, where many clients collaboratively train a global model by using the local training data under the orchestration of a central server. PeFAD contains two major modules: the PLM-based local training module and the parameter-efficient federated training module. The PLM-based local training module employs the pre-trained language model (PLM) for each client, which features an anomaly-driven mask selection strategy and a privacy-preserving shared dataset synthesis mechanism. We adopt the PLM as the body of the local model of clients because its cross-modality knowledge transfer capability <ref type="bibr">[9,</ref><ref type="bibr">14,</ref><ref type="bibr">45]</ref> can effectively address the challenge of data scarcity. Specifically, we aim to leverage the generic knowledge and the contextual understanding capability of PLM to help discern the time series patterns and anomalies. To reduce the computation and communication overhead of PLM, we propose a parameter-efficient federated training module. The clients only need to fine-tune smallscale parameters and then transfer them to the server. In order to mitigate the impact of anomalies during training, we propose a novel anomaly-driven mask selection strategy to first identify anomalies during training, and then assign them larger weights to be selected for masking. To alleviate the data heterogeneity across clients, we propose a privacy-preserving shared dataset synthesis mechanism. To be specific, each client first utilizes a variational autoencoder to synthesize privacy-preserving time series, and the synthesized data are pooled together to form a dataset shared by all clients. Then knowledge distillation is performed between local and global models with the shared dataset to achieve a more consistent model update between the clients.</p><p>Our primary contributions are summarized as follows.</p><p>&#8226; To the best of our knowledge, this is the first PLM-based federated framework for unsupervised time series anomaly detection. To reduce the computation and communication costs, we propose a parameter-efficient federated training module. &#8226; To alleviate the impact of anomalies during training, an anomaly-driven mask selection strategy is proposed, which enhances the model's adaptability towards change points, thereby improving the robustness of anomaly detection. &#8226; To deal with the data heterogeneity across clients, a novel privacy-preserving shared dataset synthesis mechanism and a knowledge distillation method are both proposed to ensure a more consistent model updating between clients. &#8226; We conduct extensive evaluations on four popular time series datasets. The result demonstrates that the proposed PeFAD significantly outperforms existing SOTA baselines in both centralized and federated settings. The remainder of this paper is organized as follows. Section 2 reviews related work and analyzes the limitations of existing work. Section 3 introduces preliminary concepts and the federated time series anomaly detection problem. We then present our solutions in Section 4, followed by the experimental evaluation in Section 5. Section 6 discuss the results to the motivation of the paper, and Section 7 concludes the paper.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">RELATED WORK 2.1 Time Series Anomaly Detection</head><p>Time series anomaly detection aims to identify unusual patterns or outliers within time series, which plays a crucial role in various real-world applications <ref type="bibr">[26,</ref><ref type="bibr">38]</ref>. Traditionally, time series anomaly detection methods are mostly based on conventional machine learning models such as support vector machine (SVM) <ref type="bibr">[26]</ref> and isolation forest <ref type="bibr">[11]</ref>. The major limitation of the above methods is that the complex temporal correlations of time series are hard to be captured due to their limited learning capability. Recently, with the advances in deep learning techniques, deep neural network models have been widely used for time series anomaly detection, which can be categorized into supervised and unsupervised methods. Supervised methods <ref type="bibr">[21]</ref> are trained on labeled data to identify deviations from normal patterns in time series. Unsupervised methods <ref type="bibr">[38,</ref><ref type="bibr">45]</ref> often calculate an anomaly score to measure the difference between the original time series and the reconstructed or predicted time series. The unsupervised methods can learn the intrinsic structure and patterns of time series beyond the labels. Nevertheless, existing time series anomaly detection methods are mostly trained with centralized data and are computational heavily, limiting their usage on resource-constrained edge devices.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2">Federated Learning</head><p>Federated learning (FL) is a machine learning approach in which many clients (commonly referred to as edge devices) collaboratively train a model using decentralized data <ref type="bibr">[5,</ref><ref type="bibr">12,</ref><ref type="bibr">13,</ref><ref type="bibr">16,</ref><ref type="bibr">24]</ref>. Typically, FL can be categorized into horizontal federated learning, vertical federated learning, and federated transfer learning based on the overlap of data features and sample space among clients <ref type="bibr">[16]</ref>. Horizontal FL <ref type="bibr">[5]</ref> is defined as the case where datasets on different clients share the same feature space but have different sample space, while vertical FL <ref type="bibr">[12]</ref> is the opposite case. In federated transfer learning <ref type="bibr">[24]</ref>, the sample space and feature space between cross-client data are virtually non-overlapping. In this study, we consider time series anomaly detection based on horizontal FL.</p><p>Recently, FL has been applied to time series with the concern of privacy protection, such as time series forecasting <ref type="bibr">[17]</ref> and anomaly detection <ref type="bibr">[10]</ref>. However, existing research lacks an in-depth exploration on how to use pre-trained language models for time series anomaly detection in a federated setting, leaving a significant gap in the existing literature. This gap can be attributed to the inherent complexities associated with reconciling domain differences and task variations within the context of federated learning when applying pre-trained language models.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">PROBLEM DEFINITION</head><p>We first present the necessary preliminaries and then define the problem addressed. To make notations consistent, we use bold letters to denote matrices and vectors.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Definition 3.1 (Time Series). A time series</head><p>Federated Time Series Anomaly Detection. Given a server S and N clients (e.g., sensors) with their local time series datasets</p><p>We aim to learn a shared global function F (&#258; ) that can detect anomalies in time series across different clients. The optimal global model parameters &#258; * &#285; is obtained as follows:</p><p>where L (&#258; &#285; ; T &#287; ) denotes the loss function for client &#287;, and &#258; &#285; denotes parameters of the global model. C denotes the set of clients.</p><p>In client &#287;, given a time series</p><p>, we aim at computing an outlier score &#267;&#271; (&#298; &#287; &#288; ) for each time point &#288;. A higher &#267;&#271; (&#298; &#287; &#288; ) means it is more likely that &#298; &#287; &#288; is an outlier. The outlier score can be formulated as follows:</p><p>where &#298;&#287; &#288; is the reconstructed value of &#298; &#287; &#288; . We consider the top &#296; % of &#267;&#271; (&#298; &#287; &#288; ) as anomalies, where &#296; is a threshold.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">METHODOLOGY</head><p>Figure <ref type="figure">2</ref> shows the framework overview of the proposed PeFAD.</p><p>As shown in the figure, PeFAD consists of two major modules: PLMbased local training (right part of the figure) and parameter-efficient federated training (left part of the figure). Specifically, in PLM-based local training module, the client first uses a patching mechanism and the anomaly-driven mask selection strategy (ADMS) to preprocess the local time series, such that the model can better understand the complex patterns of time series. Then the preprocessed data is input into the PLM-based local model for training. Specifically, the preprocessed data undergoes embedding layer, the stacked PLM blocks, and the output projection layers to finally output the reconstructed time series. Based on the reconstructed data, the client identifies the anomalous points by calculating the reconstruction error. Furthermore, a privacy-preserving shared dataset synthesis mechanism (PPDS, lower right part of the figure) is utilized to alleviate data heterogeneity across clients through knowledge distillation. To reduce computation and communication cost, we also propose a parameter-efficient federated training module. Next, we will provide the technical details of each module, respectively.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.1">PLM-based Local Training</head><p>To better capture local temporal information, the client divides the local time series into non-overlapping patches <ref type="bibr">[20]</ref>. Specifically, we aggregate adjacent time steps to create patch-based time series. This application of patching allows for a substantial extension of the input historical time horizon while keeping the token length consistent and minimizing information redundancy for transformer models. Then, we select a certain proportion of these patches for masking using an anomaly-driven mask selection strategy.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>4.1.1</head><p>Anomaly-Driven Mask Selection. Existing reconstruction based methods <ref type="bibr">[32,</ref><ref type="bibr">38,</ref><ref type="bibr">45]</ref> generally neglect the anomalies in the training data, which may disrupt mask reconstruction. For instance, if normal points are masked while anomalous points are utilized as observations to reconstruct the masked time series fragments, it may result in large reconstruction errors <ref type="bibr">[37]</ref>. To address this issue, we propose the anomaly-driven mask selection strategy to first identify the anomalies, and then assign them larger weights to be chosen for masking. The module combines the analysis on intra-and inter-patch variability to calculate the anomaly score of patches, capturing both patch-specific deviations and the contextual evolution of patterns over time. Intra-patch Decomposition. To capture the intrinsic characteristics of the &#287;-th patch (denoted as &#268; &#287; ), we utilize time series decomposition technique <ref type="bibr">[6]</ref>. Specifically, we decompose each patch into &#265; components, as formulated in Eq. ( <ref type="formula">3</ref>), and extract residual components to calculate the intra-anomaly score of patches.</p><p>where &#285; &#288; denotes the &#288;-th component, &#279; &#288; is the coefficient for &#288;-th component, and &#255; denotes the noise term. Specifically, we use Singular Spectrum Analysis (SSA) <ref type="bibr">[6]</ref> to decompose patches. In SSA, patch &#268; &#287; is first transformed into a Hankel matrix P &#287; through embedding, and then Singular Value Decomposition (SVD) is applied to the matrix, decomposing P &#287; into the product of three matrices: P &#287; = &#273; &#274; &#272; , where &#273; and &#274; denote the left and right singular vector matrices, respectively, and denotes the diagonal matrix of singular values. Then, the original patch is reconstructed by</p><p>where &#263; denotes number of non-zero eigenvalues of P &#287; . &#255; &#289; is the &#289;-th singular value, &#299; &#289; is the &#289;-th left singular vector, and &#300; &#289; is the &#289;-th right singular vector. Matrix P &#287; constitutes the main structure of the original patches. For instance, the trend, seasonal, and residual components correspond to the low, mid, and high frequency components of matrix P &#287; . We can obtain these components by filtering. Residuals often contain anomalies in the time series <ref type="bibr">[25]</ref>. Therefore, we extract the residual component after decomposition, and calculate the mean of the residual components as the residual value R &#287; , as formulated in Eq. ( <ref type="formula">5</ref>). A higher residual value indicates a larger likelihood to be an anomaly. We then normalize R &#287; to calculate the anomaly score</p><p>where subscript &#289; denotes the &#289;-th value of the matrix, and &#263; &#266; denotes the set of singular values associated with residual components obtained by filtering.</p><p>Inter-patch Similarity Assessment. The inter-patch similarity assessment provides insights into the dynamic evolution of patterns patches. Assuming A &#287; is the vector of patch &#287;, we calculate the cosine similarity between the &#287;-th and (&#287;-1)-th patches.</p><p>The cosine similarity ranges from -1 to 1, and a larger value indicates a higher similarity between patches. Patches with lower similarity to the previous patches are more likely to be anomalous, so we alter the monotonicity and normalize &#255; &#287; to calculate the anomaly score &#255; &#8242; &#287; for the &#287;-th patch. Anomaly Score of Patches. We synthesize the intra-patch time series decomposition and the inter-patch similarity assessment to obtain a final anomaly score for patch &#287; as follows:</p><p>The patches whose anomaly scores surpass a predefined threshold are considered as anomalies and are assigned larger weights to be chosen for masking. Since the masked patches are more emphasized by the model, the anomaly-driven mask selection strategy can enhances the model's adaptability towards change points, thus improving the robustness of anomaly detection.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>4.1.2</head><p>Privacy-Preserving Shared Dataset Synthesis. In federated learning, clients may have different data distributions and features, posing a data heterogeneity challenge that makes the generalization of the aggregated model difficult. To address this issue, we propose a privacy-preserving shared dataset synthesis scheme coupled with knowledge distillation.</p><p>Privacy-Preserving Shared Dataset Synthesis. Recent works have demonstrated that reducing mutual information can facilitate privacy protection in dataset generating <ref type="bibr">[40]</ref>. Inspired by this idea, we employ a constrained mutual information approach to obtain synthetic data for preserving the privacy of local data. Specifically, Client trains a variational autoencoder (VAE) model to synthesize time series T &#297;, from the local time series T . The mutual information (T ; T , ) measures the extent to which T , reveals T . Through constraining (T ; T , ), the likelihood of inferring T from T , has been reduced, thereby better protecting data privacy and facilitating the synthesis of privacy-preserving time series.</p><p>where ( , ) denotes the joint probability distribution, with ( ) and ( ) as the marginal probabilities of and , respectively. In order to ensure the validity of the synthesized time series, we introduce a constraint to maintain the distribution similarity between the synthesized and the original time series. We use Wasserstein distance to quantify this distribution similarity <ref type="bibr">[23]</ref>. A smaller Wasserstein distance indicates a lower cost of transforming from one distribution to another, implying that the two distributions are more similar. Given two time series = &#239; 1 , 2 , . . . , &#240; and = &#239; 1 , 2 , . . . , &#240;, and their cumulative distribution functions and , the Wasserstein distance can be obtained as follows,</p><p>where denotes the joint distributions between and , and ( , ) denotes the set of all joint distributions with the marginal distributions and . We use VAE to synthesize time series, which consists of an encoder and a decoder. The encoder first encodes the input time series as a feature representation, and the decoder then attempts to generate a synthesized time series based on the representation. The raw data privacy and the synthesized data validity are guaranteed by constraining mutual information and Wasserstein distance, respectively. The loss function for VAE is given by min</p><p>where L denotes the base loss function of VAE. and denote the input and latent vectors, respectively. ( | ) and ( | ) denote the output distributions of the encoder and decoder, respectively.</p><p>(&#8226;) denotes the Kullback-Leibler divergence <ref type="bibr">[30]</ref>, which can be calculated as follows:</p><p>where both ( | ) and ( ) are assumed to follow multivariate Gaussian distributions. and are the mean and standard deviation of the Gaussian distribution. Then, the server integrates the synthesized time series from clients to form a shared dataset D &#8462; . Note that time series synthesis is a one-time o ine process before local training.</p><p>Knowledge Distillation. We further perform knowledge distillation from the global model to the client models using the shared dataset to reduce the data heterogeneity across clients. Specifically, we first obtain the learned representations of the local and global models on the shared dataset separately, and then calculate the difference between the two representations. We use the consistency loss to measure this difference. Through reducing this discrepancy, the model can achieve more consistent client updates, thereby improving the performance and stability of the aggregated global model. The consistency loss is introduced as a regularization term to the local loss function as follows,</p><p>where &#710; and denote the reconstructed and real values of -th time series of client , respectively. and represent the parameters of the -th local and global model, respectively. is a parameter to trade off the two loss terms.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.2">Parameter-Efficient Federated Training</head><p>As a horizontal FL framework, PeFAD comprises a central server and several clients. The local model of each client consists of an input embedding layer, the stacked pre-trained language model (PLM) blocks, and an output projection layer, as illustrated on the right part of Figure <ref type="figure">2</ref>. GPT2 is used as the PLM <ref type="bibr">[22]</ref>. We first adopt several linear layers to embed the raw time series data into the feature representations required by the PLM. The output of PLM undergoes a fully connected layer to convert the output dimension of GPT2 to the dimension that the data reconstruction model needs <ref type="bibr">[45]</ref>.</p><p>We divide the model parameters into trainable parameters and frozen parameters , i.e. = ( , ). We frozen the majority of parameters in the PLM, that is, | | j | |. Specifically, the frozen parameters include the layer normalization blocks and the first layers ( g 5). We choose to freeze the majority of the parameters of the PLM during fine-tuning as they encapsulate most of the generic knowledge learned from pre-training phase. To enhance downstream time series anomaly detection tasks with minimal effort, we fine-tune the input-output layers and certain parts of the last one or three layers of the PLM, including the attention layer, the feed-forward layer, and positional embedding, as they contain taskspecific information and adjust them allows the model to adapt to the nuances of the target domain or task. The process of parameterefficient federated training module is given in Algorithm 1.</p><p>Training on Server Side. The server first sends trainable parameters to the clients for initialization (Lines 5). Then, client updates , through local training (Line 6). Finally, server receives parameters from all clients and aggregates them to get updated parameters , (Lines 7-8).</p><p>Local Training on Client Side. After the clients receive , from the server, they assemble the whole PLM model with trainable parameters , and frozen parameters (Line 10). The -th local model updates its parameters , by gradient descent (Lines 11-14). After the local training is completed, client sends , to the server for aggregation (Line 15).</p><p>The training process described above is repeated until PeFAD converges according to Eq. (1).</p><p>Algorithm 1: Parameter-Efficient Federated Training Input: model parameters ( , ); clients set C; global and local epoch number: and ; learning rate ; weight coefficient ; dataset D = {T 1 , T 2 , ..., T N }; local dataset T = 1 , 2 , &#8226; &#8226; &#8226; , ; Output: Trained global model . 1: Server Execute: 2: Initialize the trainable parameters 0 , ; 3: for global round = 1 to do 4: for each client &#8712; C in parallel do 5:</p><p>Client Update( , &#285; -1 , );</p><p>Receive &#285; , from all clients in C ;</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>8:</head><p>Update &#285; , by: &#285;</p><p>9: Client Update ( , &#285; -1 , ): </p><p>&#8226; &#8741;F ( ( &#285; -1, &#290; ) , D &#8462; ) -F ( &#285; -1 , D &#8462; ) &#8741;;</p><p>14:</p><p>15: Send &#285; , to the server; 16: return</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.3">Overall Objective</head><p>In this section, we give the overall objective of the proposed method. For client , it updates the local trainable model parameters by optimizing the loss function L, and sends the trainable parameters to the server.</p><p>where &#710; and denote the reconstructed and real values of -th time series of client , respectively. and represent the parameters of the -th local model and global model, respectively, composed of trainable parameters and frozen parameters .</p><p>The server aggregates trainable parameters across clients within the global iteration rounds to obtain the global model.</p><p>The time series anomaly detection for each client is achieved by leveraging the aggregated global model. To detect anomalies, we input the testing time series into the local model to obtain its reconstructed values at all time points. The anomaly score at time point is computed based on the reconstruction error as follows,</p><p>where and &#710; are the real and reconstructed values at time point , respectively.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5">EXPERIMENTS 5.1 Datasets and Experiment Setup</head><p>5.1.1 Datasets. We conduct experiments on four real-world time series anomaly detection datasets: SMD, PSM, SWaT, and MSL. The 4 datasets are widely used by existing studies and are collected from various real-world domains, covering Internet data, server operational data, critical infrastructure system data, and spacecraft monitoring system events.</p><p>&#8226; SMD. Server Machine Dataset (SMD) <ref type="bibr">[28]</ref> is a 5-week-long dataset collected from a large Internet company with 38 feature dimensions. &#8226; PSM. Pooled Server Metrics (PSM) dataset <ref type="bibr">[1]</ref> is collected from multiple application servers at eBay with 25 feature dimensions. &#8226; SWaT. Secure Water Treatment (SWaT) dataset <ref type="bibr">[15]</ref> is obtained from 51 sensors of the critical infrastructure system under continuous operations. &#8226; MSL. Mars Science Laboratory rover (MSL) dataset <ref type="bibr">[8]</ref> contains the telemetry anomaly data derived from the incident surprise anomaly reports of spacecraft monitoring systems with 55 feature dimensions.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.1.2">Baselines.</head><p>We compare PeFAD with the following 12 baselines including classical methods: OCSVM <ref type="bibr">[29]</ref>, Isolation Forest (IF) <ref type="bibr">[11]</ref> LOF <ref type="bibr">[3]</ref>, GANF <ref type="bibr">[4]</ref>, MTGFLOW <ref type="bibr">[43]</ref>, centralized reconstructionbased methods: Anomaly Transformer (AT) <ref type="bibr">[38]</ref>, TimesNet <ref type="bibr">[32]</ref>, and FPT <ref type="bibr">[45]</ref>, centralized prediction-based methods: Autoformer <ref type="bibr">[33]</ref>, Informer <ref type="bibr">[42]</ref>, and FEDformer <ref type="bibr">[44]</ref>. In addition, we transform centralized methods with FedAvg <ref type="bibr">[16]</ref> into their federated version: AT , Autoformer , Informer <ref type="bibr">[42]</ref>, and FEDformer <ref type="bibr">[44]</ref>, TimesNet , and FPT . We also compare PeFAD with the best performing model (i.e., DeepSVDD) in FedTADBench <ref type="bibr">[10]</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.1.3">Evaluation Metrics. Precision (P)</head><p>, Recall (R), F1-Score (F1), and AUC-ROC (AUC, the Area Under the Receiver Operating Characteristic curve) are adopted as the evaluation metrics. A higher value of the metrics means a better performance.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.1.4">Implementation Details.</head><p>We implement our model with the PyTorch framework on NVIDIA RTX 3090 GPU. The pre-trained language models (i.e., GPT2, BERT, ALBERT, RoBERTa, DeBERTa, DistillBERT, and Electra) are downloaded from Huggingface. We first split the time series into consecutive non-overlapping segments by sliding window <ref type="bibr">[27]</ref>. The patch length and batch size are set to 10 and 32, respectively. Adam is adopted for optimization. We adopt the widely-used point adjustment strategy <ref type="bibr">[27,</ref><ref type="bibr">28,</ref><ref type="bibr">36]</ref>. We employ GPT2 as the PLM, where the first eight layers of GPT2 are used for training. is set to 1 1, 2 0, 2 3, and 15 4 for SMD, PSM, SWaT, and MSL, respectively. The threshold for SMD, MSL, PSM, and SWaT is set to 0.5, 2, 1, and 1, respectively.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.2">The Main Result</head><p>Table <ref type="table">1</ref> shows the performance comparison among different methods under the federated and centralized settings on four datasets.</p><p>In the federated setting, the best performance is marked in bold and the second-best result is underlined. In the centralized setting, the best performance is marked in red. We use PeFAD to represent the centralized version of PeFAD.</p><p>From Table <ref type="table">1</ref>, one can see that PeFAD achieves the best performance in terms of F1-Score and AUC compared to all federated baselines on all four datasets, and even exceeds all centralized baselines on SMD and PSM datasets. More specifically, PeFAD outperforms the federated baselines by an average of 3.83%-28.74% and 3.42%-19.82% in terms of F1-Score and AUC metrics, respectively. Moreover, one can observe that PeFAD shows the best overall performance under the centralized setup. FPT exhibits sub-optimal integrated performance in the centralized baselines, which also utilizes PLM. It demonstrates the effectiveness of PLM in the task of time series anomaly detection. However, the performance of FPT under the federated setting shows a degradation. For example, PeFAD outperforms FPT by 9.85% and 7.37% for F1-Score and AUC metrics on SMD, respectively. This might be attributed to the fact that FPT does not employ parameter-efficient tuning methods suitable for federated training, and the redundant parameters may affect the model performance.</p><p>A decreasing trend of performance is observed when transferring the baseline models from the centralized setting to federated setting, indicating that time series anomaly detection has become more difficult in federated environment. This is possibly due to the data sharing restrictions, which limit clients to use less data for model training. However, PeFAD demonstrates the best overall performance in both federated and centralized settings, indicating its robust adaptability to environmental changes. It can also be observed that in some cases (i.e. SMD dataset), the performance of PeFAD surpasses PeFAD . This may be attributed to the diversity of time series data. Through federated learning, models trained on each local device can better capture the diversity of its local data. Clients can obtain more adaptive thresholds based on the characteristics of their local data, whereas a single threshold obtained under the centralized setup may fail to accommodate the entire data.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.3">Ablation Study</head><p>To gain insight into the effects of key aspects of PeFAD, we compare the performance of PeFAD with its four variants as follows. : PeFAD without pre-trained language model (PLM) and it is replaced by transformer. We conduct experiments on SMD and MSL, which have the largest and smallest data volumes, respectively. The results are shown in Figure <ref type="figure">3</ref>. On both datasets, PeFAD always outperforms its counterparts without PPDS, ADMS, and PLM. It shows the three components are all useful for time series anomaly detection since removing any one of them will remarkably decrease the performance.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.4">Effect of Tuning Strategies and PLMs</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.4.1">Effect of various tuning strategies.</head><p>To test the effect of different tuning strategies of PLM, we compare PeFAD with strategies of fine-tuning different numbers of PLM layers, including no fine-tuning (w/o_ft), tuning the last one to seven layers of PLM (PeFAD_t1l -PeFAD_t7l), and fully fine-tuning (PeFAD_fft). The result is shown in Table <ref type="table">2</ref>. We use GPT2-based FPT as a reference. One can observe that freezing the first layers while fine-tuning the last few layers is a reasonable tuning strategy. By freezing the first layers, the model retains the ability to understand generalized knowledge, and fine-tuning the last few layers facilitates the model's adaptation to downstream tasks, enabling the transfer of domain-specific knowledge from the pre-trained model to the time series anomaly detection task. Specifically, for the SMD dataset with more training data, PeFAD remains relatively stable with different tuning layers, and achieves optimal performance when tuning the last 3 and 4 layers. For the smaller MSL dataset, the model performance decreases with the increase of tuning layers, reaching optimal performance when tuning the last layer. The experiments on other datasets are provided in the appendix due to space limitation. In PeFAD, we choose to fine-tune the last layer for MSL and fine-tune the last three layers for the other datasets.</p><p>The result shows that our approach consistently outperforms FPT regardless of the number of tuning layers. Compared with FPT, PeFAD achieves the performance improvement of 9.85% and 7.09% in terms of F1-Score on SMD and MSL, respectively. Pe-FAD reduces the communication cost by 41.2% and 94.9%, which shows the efficiency of PeFAD and the effectiveness of the proposed parameter-efficient federated training module. Furthermore, PeFAD without fine-tuning (w/o_ft</p><p>) outperforms all federated baselines on both datasets, which demonstrates the superior cross-modality knowledge transfer ability of PLM. PeFAD_fft does not achieve the best performance on both datasets while tuning less, especially last few layers, works better. This is because the initial layers of PLM contain generic knowledge and the last layers are better suited to learn task-specific information. However, due to the scarcity of anomalous data, fully fine-tuning may increase the risk of overfitting, leading to performance degradation.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.4.2">Effect of various</head><p>PLMs. Next, we study the effect of using different PLMs on the model performance. We compare seven mainstream pre-trained models, i.e., BERT, ALBERT, RoBERTa, DeBERTa, DistilBERT, and Electra. The results are presented in Figure <ref type="figure">4</ref>. One can see that GPT2 achieves the best performance followed by De-BERTa. Compared to other PLMs, GPT2 improves the performance by up to 6.22% and 5.06% on F1-Score and AUC metrics on SMD, respectively. On the MSL dataset, the F1-Score and AUC values are improved by up to 8.84% and 6.99%, respectively. This is because GPT2 has been exposed to a broader range of contexts during pre-training, enabling it to learn from time series more effectively.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.5">Parameter Sensitivity Analysis</head><p>5.5.1 Effect of various mask ratio and patch length . We next study the sensitivity of the model to the mask ratio and patch length , We only give the result of F1-Score on SMD as an example due to space limitation, as shown in Figure <ref type="figure">5(a)</ref>. One can observe that the incorporation of masking or patching mechanisms can improve the model performance, demonstrating the effectiveness of these two mechanisms. As the and increase, the model performance first improves and then declines. The optimal model performance is achieved when is 20% and is 10.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.5.2">Effect of synthetic series length.</head><p>We next investigate the effect of synthetic data length on model performance, and the result is shown in Figure <ref type="figure">5</ref>(b). Specifically, we vary the length of the synthetic time series for each client on the SMD dataset. We observe that the F1-Score curve first increases and then drops slightly. Generally, the result demonstrates that the model obtains the best performance when the length of the synthetic time series is set to 100. With the increase of length from 20 to 100, the synthetic</p><p>Mask ratio (&#45163;&#27582; m ) 20% 40% 60% 80% 1 5 10 20 50 The length of patch (&#45163;&#27570; &#45163;&#27578; ) 70.50 89.55 91.34 89.22 89.70 77.70 89.37 90.68 89.09 89.70 67.00 88.75 89.86 90.07 87.07 70.85 89.06 89.06 88.69 87.87 0% 67.50 88.56 89.49 89.30 88.16  time series may bring more useful information, which facilitates the model with more effective representation learning. However, a too large length value will lead to performance decline. This is because longer synthetic time series may bring redundant or noisy information, which degrades the model performance.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.6">Case Study</head><p>To intuitively show the effectiveness of the proposed PeFAD, we provide a case study on SMD, as illustrated in Figure <ref type="figure">6</ref>. Figure <ref type="figure">6(a)</ref> shows the distribution of the real and synthesized time series, estimated by Kernel Density Estimation. The blue curve in the figure represents the real time series, the orange curve represents the synthesized time series obtained solely through mutual information (MI) constraint, the red curve represents the synthesized time series obtained solely through Wasserstein distance (WD) constraint, and the green curve represents the time series synthesized under the combined constraints of MI and WD. One can see that the orange curve exhibits a significant difference from the blue curve, while the red curve closely resemble the real distribution (blue curve). This is because solely reducing mutual information neglects considerations on the quality of the synthesized data. However, the green curve both ensures distributional similarity and protects the privacy of the data through mutual information.</p><p>Figure <ref type="figure">6</ref>(b) shows an example of time series reconstruction and anomaly detection on the SMD dataset during testing within the client. One can observe that the estimated values at normal points closely approximate the true values, while at anomalous points, the estimates align more closely with reasonable values unaffected by anomalies. Thus the anomalies in the time series are successfully identified by assessing the disparity between estimated and actual values. This is probably attributed to the proposed ADMS strategy and the PPDS mechanism, which empower the model to better adapting to complex patterns, thereby contributing to the effectiveness of time series anomaly detection.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6">DISCUSSION</head><p>We conduct comprehensive experiments, showing that PeFAD outperforms state-of-the-art baselines in terms of both centralized and federated methods. The results demonstrate the powerful representation learning capability of PLM. In addition, the proposed PPDS module also improves stability under FL. The ablation study further verifies the effectiveness of the three major components of PeFAD (i.e., PLM, ADMS, and PPDS). Specifically, the ADMS  strategy makes the model focus more on changing regions in the time series by capturing intra-and inter-patch dynamics changes. As time series often change frequently with time evolving, enhancing the model's capability in learning such changes can facilitate the proposed model to learn representative features. Moreover, the PPDS mechanism helps the model achieve more consistent client updates, thereby improving the performance and stability of the aggregated global model. Moreover, we also verify that the proposed efficient tuning strategy reduces communication overhead effectively.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7">CONCLUSION</head><p>This work presents PeFAD, a federated learning framework for time series anomaly detection. Different from previous methods, we aim to leverage the generic knowledge and the contextual understanding capability of the pre-trained language model to address the data scarcity problem. To alleviate the communication and computation burden in federated learning brought by PLM, we propose a parameter-efficient federated training module, where clients only need to fine-tune and transmit small-scale parameters. Moreover, PeFAD features a novel anomaly-driven mask selection strategy to refine the quality of time series reconstruction, thereby improving the robustness of anomaly detection. In order to address the issue of client heterogeneity, a privacy-preserving shared dataset synthesis mechanism is also proposed, enabling clients to learn more consistent and comprehensive information. Extensive experiments on four real work datasets show the effectiveness and efficiency of the proposed PeFAD.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="8">ACKNOWLEDGEMENT</head><p>worst, which demonstrates the effectiveness of PLM on the task of federated anomaly detection.</p><p>SWaT PSM PeFAD w/o_ppds w/o_adms w/o_plm 80 85 90 95 100 F1-Score (a) F1-Score SWaT PSM PeFAD w/o_ppds w/o_adms w/o_plm 80 85 90 95 100 F1-Score (b) AUC To further explore the effects of various variants on PeFAD performance, we conducted more detailed ablation experiments.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>&#8226; / _</head><p>. PeFAD without the shared dataset synthesis scheme.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>&#8226; / _</head><p>. PeFAD without ADMS strategy replaced by random masking.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>&#8226; / _</head><p>. PeFAD without pre-train language model (PLM) replaced by transformer.</p><p>&#8226; / _( -). PeFAD without intra-patch time series decomposition when calculating the anomaly score of patches, which means the hyper-parameter is equal to 0.</p><p>&#8226; / _( -). PeFAD without inter-patch similarity assessment when calculating the anomaly score of patches, which means the hyper-parameter is equal to 1.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>&#8226; / _</head><p>&amp; . PeFAD without PPDS and ADMS.</p><p>The results on the SMD and MSL datasets are shown in Figure <ref type="figure">8</ref>. One can see that these four components all improve the anomaly detection performance of PeFAD. For example, removing these components decreases the F1-Score and AUC values by up to 6.77% and 5.72% on MSL, respectively. On both datasets, / _ &amp; performs the worst among all variants on both datasets, showing the benefit of PPDS mechanism and ADMS strategy. Further, / _ performs second-worst in terms of F1-Score, indicating the validity of the PLM. Specifically, on both datasets, / _ &amp; performs the worst among all variants. PeFAD outperforms / _ &amp; , improving the performance by up to 6.15% and 4.95% in terms of F1-Score and AUC, respectively A.2.2 Effect of Various Tuning Strategies. We further investigate the effect of various tuning strategies on PSM and SWaT datasets. The results are shown in Table <ref type="table">3</ref>. It can be seen that the best choice for the PSM dataset is to fine-tune the last 3 layers, and for the SWaT dataset fully fine-tuning and fine-tuning the last three layers achieve similar performance. To reduce computation cost, we finetune the last three layers in PeFAD in practice for SWaT. In addition, compared to the FPT , PeFAD which fine-tunes the last three layers shows better performance and lower communication overhead on both PSM and SWaT datasets, which demonstrates the effectiveness of the parameter-efficient federated training module.  following layers: the position embedding layer (pe), the layer norm (ln), the attention layer (att), and the feedforward layer (ff). We conduct experiments on the SMD dataset, and the result is shown in Fig 9 . We only fine-tune the last three layers, and it can be observed that fine-tuning the blocks of pe, att, and ff is the optimal fine-tuning solution. It is because these blocks contain task-specific information and adjusting them allows the model to adapt to the nuances of the target domain or task.</p><p>A.2.4 Parameter Sensitivity Analysis.</p><p>(1) Effect of client numbers. We investigate the effect of client numbers on the model performance over SMD, the result is shown in Figure <ref type="figure">10(a)</ref>. We observe that the model achieves optimal performance when the number of clients is set to 14, and when the number of clients exceeds 14, the model performance decreases as the number of clients increases. This is because as the number of clients increases, the model may become more prone to overfitting each individual client. This could lead to an overall performance decline.</p><p>ln ln&amp;ff ln&amp;pe ln&amp;att 90.0 90.5 91.0 91.5 92.0 F1-Score (a) F1-Score ln ln&amp;ff ln&amp;pe ln&amp;att 96.0 96.5 97.0 97.5 98.0 AUC (b) AUC AUC F1-Score 2 6 10 14 18 22 26 30 34 38 76 82 88 94 100 Performance (a) The effect of client numbers AUC F1-Score 20 40 60 80 100 120 140 160 180 260 84 88 92 96 100 Performance (b) The effect of synthetic data length AUC F1-Score 0 0.2 0.4 0.6 0.8 1 82 88 94 100 Performance (a) Effect of in ADMS AUC F1-Score 0.3 0.4 0.5 0.6 0.7 82 88 94 100 Performance (b) Effect of 2 in PPDS Figure 11: Effects of hyperparams in ADMS and PPDS.</p><p>(2) Effect of synthetic data length. We investigate the synthetic data length on model performance by varying the length of the client-synthesis time series on the SMD, the result is shown in Figure <ref type="figure">10</ref>(b). One can observe that the model is relatively robust to the different sizes of the synthesized time series, and the model performs best when the length of synthesized time series is set to 100.</p><p>(3) Effect of hyperparameters in ADMS and PPDS. We conduct experiments on the hyperparameter (i.e., &#255; and &#258; 2 ) sensitivity of ADMS and PPDS on SMD, as shown in Figure <ref type="figure">11</ref>. The results show that the fluctuation of the model's performance is not significant as the hyperparameters are varied, especially for the hyperparameters in the PPDS module. For the ADMS module, there is little change in model performance when &#255; is between 0.2 and 0.8, while there is a decrease in model performance at &#255; = 0 or 1, suggesting that both residual and cosine similarity terms are beneficial for model training.</p><p>A.2.5 Case Study. We visualized two samples from the training and testing process and their reconstructed time series, respectively. Figure <ref type="figure">12</ref> shows examples of series reconstruction during training</p><p>0 20 40 60 80 100 0.2 0.4 1.0 1.6 2.2 Observations Real TS Reconstructed TS (a) A reconstruction example in training Real TS Reconstructed TS Anomaly point 0 20 40 60 80 100 1.1 0.8 0.5 0.2 0.1 Observations (b) A reconstruction example in testing  </p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_0"><p>This research was funded by the National Science Foundation of China (No.62172443), the Science and Technology Major Project of Changsha (No.kh2402004) and Hunan Provincial Natural Science Foundation of China (No.2022JJ30053). This work is supported in part by NSF under grants 2106758, and 2346158. This work was carried out in part using computing resources at the High-Performance Computing Center of Central South University.</p></note>
		</body>
		</text>
</TEI>
