Papers
Topics
Authors
Recent
Search
2000 character limit reached

RGFiLM: Rarity-Aware Feature-wise Modulation

Updated 5 July 2026
  • The paper introduces RGFiLM, which conditions feature-wise modulation on empirically computed rarity scores to improve anomaly detection in imbalanced contexts.
  • It integrates FiLM for feature-wise affine transformations with a rarity-controlled gate that decisively interpolates between original and modulated representations.
  • Empirical results on maritime AIS data show enhanced F1 scores and reduced false positives, especially under rare environmental conditions.

Searching arXiv for RGFiLM and closely related FiLM/gated modulation papers to ground the article. Rarity-Gated Feature-wise Linear Modulation (RGFiLM) is a rarity-aware context-conditioning module for contextual anomaly detection in which context generates feature-wise affine modulation parameters, while a separate gate—controlled by a data-driven rarity score—regulates how strongly the context-modulated representation should replace the original hidden state. In its reported instantiation, RGFiLM is inserted into an offline imitation learning-based maritime anomaly detector operating on AIS motion sequences with ERA5 environmental context, and is motivated by the observation that standard context-conditioned models can become unstable under highly imbalanced context distributions, particularly in rare but operationally important regimes. The defining claim of the method is not merely that context should be incorporated, but that the manner of conditioning should depend on empirical context rarity (Kim et al., 11 Jun 2026).

1. Contextual anomaly detection under imbalanced contexts

RGFiLM is formulated for contextual anomaly detection, where anomalousness depends on the conditional distribution p(b∣c)p(\mathbf{b}\mid \mathbf{c}), with b\mathbf{b} denoting behavior and c\mathbf{c} denoting context. The sequential setting is central. A trajectory is represented as

Ï„={(st,et,at)}t=1T,\tau=\{(s_t, e_t, a_t)\}_{t=1}^T,

where sts_t is state at time tt, ete_t is exogenous environmental context, and ata_t is an action or discretized decision. In the maritime case study, route deviations may be abnormal in calm conditions yet acceptable under severe weather, so anomaly scoring cannot be divorced from context (Kim et al., 11 Jun 2026).

The paper frames the core difficulty as frequency bias induced by imbalanced context distributions. Frequent contexts dominate training and are well fitted; rare contexts are underrepresented and can yield unstable or poorly calibrated context-conditioned responses. The reported consequence is excessive false alarms or overreaction to context in rare regimes. RGFiLM is therefore designed against a specific failure mode of ordinary context integration: standard FiLM or concatenation-based conditioning implicitly assumes sufficient support over the context distribution, whereas RGFiLM treats rarity itself as a control variable (Kim et al., 11 Jun 2026).

A recurrent misconception addressed by the formulation is that rare context should simply induce stronger context usage. The method does not adopt that rule. Instead, it sharpens the decision over whether the model should trust the context-modulated representation or fall back toward the original latent state. The distinction is operationally important: rarity modulates the decisiveness of interpolation, not a monotonic increase in contextual reliance (Kim et al., 11 Jun 2026).

2. Formal definition and gating mechanism

RGFiLM begins with a state encoder that produces a hidden representation

ht=fstate(s1:t),\mathbf{h}_t = f_{\text{state}}(s_{1:t}),

and an environment encoder that maps context to FiLM parameters

(γt,βt)=fenv(et).(\boldsymbol{\gamma}_t, \boldsymbol{\beta}_t)=f_{\text{env}}(e_t).

These parameters define the context-modulated hidden state

b\mathbf{b}0

with b\mathbf{b}1 denoting element-wise multiplication. This is the FiLM component proper: context-conditioned feature-wise scaling and shifting of latent features (Kim et al., 11 Jun 2026).

The distinctive addition is a rarity-controlled gate. Rarity is computed from a selected context subvector b\mathbf{b}2; in the reported experiments,

b\mathbf{b}3

From normal training data, the method estimates a mean vector b\mathbf{b}4 and covariance matrix b\mathbf{b}5, then computes a Mahalanobis distance

b\mathbf{b}6

Assuming a multivariate Gaussian approximation, the rarity score is

b\mathbf{b}7

where b\mathbf{b}8 is the chi-squared CDF with b\mathbf{b}9 degrees of freedom. Thus c\mathbf{c}0, with small values denoting common contexts and large values denoting rare or extreme contexts (Kim et al., 11 Jun 2026).

The gate first computes

c\mathbf{c}1

where c\mathbf{c}2 is a small neural network operating on the concatenation of raw context and rarity. Rarity-dependent sharpening is then applied by

c\mathbf{c}3

with base temperature c\mathbf{c}4 and rarity sensitivity c\mathbf{c}5. The scalar gate is

c\mathbf{c}6

and the final RGFiLM output is

c\mathbf{c}7

Equivalently, RGFiLM interpolates between the original representation and the FiLM-modulated representation using a rarity-aware mixing coefficient (Kim et al., 11 Jun 2026).

Two structural properties follow directly from this definition. First, FiLM is feature-wise, since c\mathbf{c}8 match the hidden dimension. Second, the rarity gate is scalar per time step, so interpolation is global across the latent vector at that step. A plausible implication is that RGFiLM separates what to modulate at feature level from how much to trust the modulated state at representation level.

3. Architectural insertion and anomaly-scoring pipeline

RGFiLM is integrated into the OIL-AD framework by replacing the original state representation with c\mathbf{c}9 wherever the state encoder output is used. The insertion point is therefore after sequence encoding and before the downstream OIL-AD heads. The sequence of computation is: encode AIS trajectory history into Ï„={(st,et,at)}t=1T,\tau=\{(s_t, e_t, a_t)\}_{t=1}^T,0, encode environmental context into Ï„={(st,et,at)}t=1T,\tau=\{(s_t, e_t, a_t)\}_{t=1}^T,1, form Ï„={(st,et,at)}t=1T,\tau=\{(s_t, e_t, a_t)\}_{t=1}^T,2, compute rarity score Ï„={(st,et,at)}t=1T,\tau=\{(s_t, e_t, a_t)\}_{t=1}^T,3 and gate Ï„={(st,et,at)}t=1T,\tau=\{(s_t, e_t, a_t)\}_{t=1}^T,4, then pass Ï„={(st,et,at)}t=1T,\tau=\{(s_t, e_t, a_t)\}_{t=1}^T,5 to the action and monotonicity heads (Kim et al., 11 Jun 2026).

The broader anomaly detector remains an offline imitation learning pipeline. AIS state is

Ï„={(st,et,at)}t=1T,\tau=\{(s_t, e_t, a_t)\}_{t=1}^T,6

and actions are discretized into five categories: up, right, down, left, and stay. Environmental context is aligned from ERA5 as

Ï„={(st,et,at)}t=1T,\tau=\{(s_t, e_t, a_t)\}_{t=1}^T,7

RGFiLM does not alter the original OIL-AD objective structure; the paper states that the action loss and monotonicity loss are retained unchanged, with Ï„={(st,et,at)}t=1T,\tau=\{(s_t, e_t, a_t)\}_{t=1}^T,8 replacing Ï„={(st,et,at)}t=1T,\tau=\{(s_t, e_t, a_t)\}_{t=1}^T,9 in the latent pathway (Kim et al., 11 Jun 2026).

At inference time, the model produces time-step anomaly evidence sts_t0, and the trajectory-level anomaly score is

sts_t1

A threshold is selected on the validation set and applied to the test set. Models are trained only on normal training trajectories; anomalies are synthetically injected only in validation and test data. The reported preprocessing follows OIL-AD: AIS messages are sorted by timestamp, cleaned, and temporally regularized; trajectories are split at stationary segments when vessel speed remains at sts_t2 for more than a fixed number of consecutive steps; retained segments satisfy length sts_t3 and are not dominated by near-stationary behavior (Kim et al., 11 Jun 2026).

The experimental dataset is an AIS–ERA5 corpus for the Bass Strait region in Australia covering July 2020 to December 2020. The principal benchmark is an environment-sensitive detour scenario in which anomalous validation and test trajectories are created by modifying a contiguous subsegment with an approximately sts_t4 eastward longitude shift before rejoining the original path, while leaving the environmental sequence unchanged. This design makes the anomaly injection environment-invariant and tests whether context-sensitive conditioning can reduce false alarms without legitimizing the injected detour (Kim et al., 11 Jun 2026).

4. Empirical behavior, ablations, and rare-context effects

The evaluation protocol uses 20 random seeds, a 10:1 normal-to-anomaly ratio in validation and test, and reports mean sts_t5 standard deviation over runs for Precision, Recall, F1 score, and False Positive Rate (FPR). The paper emphasizes the F1–FPR trade-off rather than accuracy-like summaries alone (Kim et al., 11 Jun 2026).

In the main comparison, RGFiLM achieves

sts_t6

Relative to OIL-AD without environmental context, F1 improves from sts_t7 to sts_t8 and FPR decreases from sts_t9 to tt0. Relative to standard FiLM, F1 improves from tt1 to tt2, Recall improves from tt3 to tt4, and FPR remains essentially unchanged at tt5. Relative to OIL-AD + Gated FiLM (no rarity), F1 improves from tt6 to tt7 and FPR decreases from tt8 to tt9 (Kim et al., 11 Jun 2026).

The gated-FiLM ablation is the most direct isolation of the rarity term. It shows that gating alone is beneficial, FiLM alone is beneficial, and rarity-aware sharpening contributes additional false-positive reduction beyond either component individually. Paired Wilcoxon signed-rank tests over matched seeds show significant improvements in F1 and FPR over OIL-AD and Concat at ete_t0, and a significant FPR reduction over OIL-AD + Gated FiLM with ete_t1. The paper explicitly notes that the strongest significant gains are concentrated in false-alarm reduction (Kim et al., 11 Jun 2026).

The rare-context analysis further clarifies the intended behavior. Trajectories are stratified by environmental rarity into frequent (bottom 80%) and rare (top 20%). All methods degrade in rare contexts, but RGFiLM attains the highest mean F1 in both regimes—ete_t2 in frequent and ete_t3 in rare—and the lowest mean FPR in both—ete_t4 in frequent and ete_t5 in rare. The reported gain over FiLM is larger in the rare regime, from ete_t6 to ete_t7, than in the frequent regime, from ete_t8 to ete_t9. This suggests that rarity-aware gating is most useful precisely where empirical context support is weakest (Kim et al., 11 Jun 2026).

The mechanism behind this pattern is the sharpening factor ata_t0. As ata_t1 increases, the magnitude of the sigmoid input grows for fixed ata_t2, pushing ata_t3 closer to ata_t4 or ata_t5. The intended effect is therefore a more confident decision between preserving ata_t6 and trusting ata_t7 in rare regimes, rather than a blanket amplification of context. The reported validation-selected hyperparameters are ata_t8 and ata_t9 (Kim et al., 11 Jun 2026).

5. Relation to FiLM and adjacent gated-modulation architectures

RGFiLM belongs to the broader family of feature-wise affine modulation methods, but its novelty lies in coupling FiLM with a rarity-conditioned interpolation gate. In standard FiLM formulations, hidden features are modulated as ht=fstate(s1:t),\mathbf{h}_t = f_{\text{state}}(s_{1:t}),0, with conditioning supplied by some external variable. That paradigm appears across domains including graph message passing, where target-node representations generate feature-wise affine transformations over incoming messages in GNN-FiLM (Brockschmidt, 2019), and implicit ensembling, where member-specific FiLM parameters define low-overhead ensemble diversity in FiLM-Ensemble (Turkoglu et al., 2022).

What distinguishes RGFiLM from those formulations is not the affine operator itself, but the explicit use of an empirical rarity score to regulate the influence of the FiLM-modulated state. In that respect it is closer to recent work in which FiLM is embedded inside higher-level routing or control structures. The deweathering MoFME architecture replaces full experts with feature-wise affine modulation branches routed by an uncertainty-aware router; routing calibrates how much each modulation expert contributes, while the downstream FFN weights are shared (Zhang et al., 2023). RGFiLM is structurally different—its gate interpolates between original and modulated representations rather than routing among multiple modulation experts—but both methods treat affine modulation as a substrate for conditional control rather than as a stand-alone conditioning primitive.

The contrast with FiLoRA is sharper. FiLoRA performs instruction-conditioned gating over grouped LoRA adaptation pathways,

ht=fstate(s1:t),\mathbf{h}_t = f_{\text{state}}(s_{1:t}),1

so natural-language instructions modulate reliance on predefined computation paths while keeping the task objective fixed (Chung et al., 2 Feb 2026). This is group-wise/module-wise soft routing over low-rank adaptation branches, not feature-wise affine modulation. RGFiLM instead modulates hidden features directly via FiLM and then gates the resulting representation using a rarity signal. The two methods therefore share the goal of controllable internal reliance but operate at different levels of the model.

RGFiLM also differs from finer-grained modulation schemes that extend FiLM beyond feature-wise conditioning. SongEcho introduces Instance-Adaptive Element-wise Linear Modulation, where modulation parameters match the full hidden-state tensor and are refined using current hidden states before application (Li et al., 23 Feb 2026). Relative to such element-wise schemes, RGFiLM is architecturally simpler: the FiLM component is feature-wise, while the rarity gate is scalar per time step. A plausible implication is that RGFiLM prioritizes robustness and interpretability of context usage over maximal modulation granularity.

6. Limitations, scope, and prospective extensions

The reported evaluation is deliberately narrow. It uses synthetic detour injection with fixed magnitude, one geographic region, one time period, and one anomaly family. The rarity estimator relies on a Gaussian approximation over selected environmental variables and may be sensitive to limited coverage of environmental regimes or to context-domain shift. The paper also leaves several implementation details under-specified, including the exact architectures of the gate network ht=fstate(s1:t),\mathbf{h}_t = f_{\text{state}}(s_{1:t}),2, the environment encoder ht=fstate(s1:t),\mathbf{h}_t = f_{\text{state}}(s_{1:t}),3, and the sequence encoder ht=fstate(s1:t),\mathbf{h}_t = f_{\text{state}}(s_{1:t}),4, beyond noting that OIL-AD-based variants share the same batch size, learning rate, and epochs to isolate the conditioning mechanism (Kim et al., 11 Jun 2026).

These constraints matter for interpretation. The method establishes that rarity-aware gating improves the F1–FPR trade-off in the reported maritime detour setting, but it does not demonstrate universality across contextual anomaly detection tasks. Likewise, the Mahalanobis-plus-chi-squared rarity score is presented as a simple and efficient choice rather than a definitive density estimator. The paper explicitly notes that other density-based scores could replace the chosen rarity metric (Kim et al., 11 Jun 2026).

From a broader FiLM perspective, several extension paths are suggested by adjacent literature, though they are not part of RGFiLM as reported. Fine-grained temporal or element-wise gating, as explored in SongEcho (Li et al., 23 Feb 2026), could increase sensitivity to localized rare events. Routing among multiple modulation experts, as in MoFME (Zhang et al., 2023), could separate distinct rare-context regimes. Instruction- or taxonomy-conditioned control over reliance, analogous to FiLoRA’s grouped gating (Chung et al., 2 Feb 2026), could provide a more explicit mechanism for distinguishing semantically central versus incidental contextual factors. These possibilities are extrapolations rather than claims of the RGFiLM paper.

In its reported form, RGFiLM is best understood as a modular representation-conditioning mechanism for imbalanced contextual regimes: FiLM supplies context-conditioned feature-wise affine transformation, rarity sharpens a scalar interpolation gate, and the resulting hybrid reduces false alarms without discarding context outright. Its principal contribution is therefore conceptual as much as empirical: rare context is treated neither as noise to ignore nor as signal to amplify indiscriminately, but as a cue for controlling the confidence of contextual modulation (Kim et al., 11 Jun 2026).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Rarity-Gated Feature-wise Linear Modulation (RGFiLM).