Night Shift

Control room: a replay of recorded answers

Replay of recorded answers on recorded plant data (check set).

Instruments

Central control

Watching

Filled mark: a model says attack. Outlined mark: a model says normal.

The model answers once, after all 300 seconds are in.

Reading: each window goes in with its feature lines, and seven models vote on it.

In the loop's curves, plus one feature line per curve

Seven models read it and vote

Out attack or normal, the start second, one sentence

Until then this panel stays neutral: no verdict, no alarm.

How to read the instruments

Each instrument draws the curves the model reads for that loop: targets, measurement and commands, one lane each, the measurement lane taller.

The gauges follow the measurement on the same lane scale: the dial's needle, the tank's level, the thermometer's column, and the small marks under the rotor and the pipe, where the centre tick is the starting level. The rotor turns and the pipe's marks move at a rate in proportion to the measured speed and flow. A tank's surface ripples only while its level changes. A target mark is drawn only where the target is in the measurement's units. Schematic for illustration, not the plant's real piping.

Built with Llama · Data: HAI dataset, CC BY-SA 4.0 · Schematic for illustration, not the plant's real piping

OpenTSLM model for monitoring power plant telemetry to explain & find attacks.

We took OpenTSLM-SP, a time-series language model built on Llama 3.2 1B, and trained it further on data from a lab power plant. It reads 300 seconds of one control loop: a target, a measurement and a command. It answers three things: attack or normal, the second the attack began, and one sentence on what it saw.

We compared it with gradient boosting, a standard statistical method. On the test set, run once, gradient boosting scores 54 of a perfect 82. Three of our models voting score 51, seven score 50.

Why use an OpenTSLM model? It explains its call with a start second and a sentence, which gradient boosting does not give. And three of our models voting are far more accurate than Kimi K3.1 Pro, a much larger general-purpose model that was not trained on the plant, at about a third of the cost.

The data: a lab power plant with 198 staged attacks. They are short and rare.

HAI is a public dataset from a lab-scale power plant: a boiler, a turbine and a water treatment process, real hardware coupled to a simulation. It records the plant's sensors and actuators once a second. Its four releases hold about 620 hours of data.

The plant runs on control loops. Each loop has a target (the value the controller aims for), a measurement (what the sensor reads) and a command (what the controller sends to a valve or pump). We watch six loops: boiler pressure, boiler level, boiler flow, boiler temperature, turbine speed and water level.

The problem: attacks. In 196 of the 198 attacks, someone changes a loop's target or its command. In 72 of them, the attacker also freezes the measurement at its last value, to hide the change. Half of the attacks last under three minutes. Together they cover 2% of the recording.

The task. We cut the recordings into windows of 300 seconds and look at one loop at a time. For each window the question is: is this loop under attack, and from which second?

One real attack on the boiler level loop. It starts at second 112.

One window: 300 seconds of one loop. Target, measurement and command, each in its own band. Source: HAI dataset, CC BY-SA 4.0.

Three sets. We split the windows by recording file, so no attack appears in two sets. The models learn from the training set. We compare designs on the check set. We use the test set once, at the end.

SetWindowsAttack windowsUsed for
Training3,880, a sample of 18,636776teaching the models
Check set1,092144, from 15 attacksevery design choice
Test set1,53682, from 56 attacksthe final result, run once

The score. We count the attack windows caught and subtract the false alarms, which are normal windows called attack. Calling everything an attack does not pay. A perfect score is 144 on the check set and 82 on the test set.

Three things make the task hard.

  • Attacks are rare. Most windows are normal, so a nervous detector drowns in false alarms.
  • Loops react to each other. When one loop is attacked, its neighbours can move too. We label those neighbours normal, so the model must not flag them.
  • Some attacks barely show. In 12 of the check set's 144 attack windows, a simple rule finds no visible change in the loop's curves.

We checked the labels first. The dataset marks each attack second by second. Its manual also lists the attacks in a table. The two agreed for only 49 of the 198 attacks; most of the others were one second apart. The repository lists every fix.

The baseline: gradient boosting trains in 5 seconds and sets a high bar.

Before training any language model, we built two simple comparisons.

The weak one: a range alarm. It rings when a measurement leaves the range seen in normal operation. On the check set it catches 49 of 144 attack windows and raises 113 false alarms. Its score is −64. Always answering "normal" would score 0.

The strong one, our baseline: gradient boosting. It is a standard statistical method that combines many small decision trees, the same family as XGBoost. We used the scikit-learn version with its default settings. It never sees the curve itself. We first reduce each curve to seven numbers, such as its spread and its largest one-second jump. We add a few numbers on how the measurement moves against the target and the command. It trains on the same 3,880 windows as our model, in 5 seconds on a laptop.

On the check set it catches 108 of 144 attack windows with 26 false alarms. Its score is 82. A second version also sees the other five loops and scores 87.

What it does not give. It answers attack or normal. It does not say when the attack began or what moved.

Check-set score of the two comparisons, of a perfect 144.

Score = caught − false alarms, on the 1,092 check windows. The range alarm is below zero. Source: HAI dataset, CC BY-SA 4.0.

Training: 64 runs. Numbers computed from the curves helped most.

The model. OpenTSLM-SP joins Llama 3.2 1B, a small language model, to a curve encoder. The encoder turns each curve into input the language model can read next to ordinary text. We trained the encoder, the link between the two, and small add-on weights inside the language model, on the 3,880 training windows. The language model's own weights stayed fixed.

What the model reads. For each window the model gets one instruction and two kinds of input.

  • The curves. 300 seconds of the loop's target, measurement and command. The curve encoder turns each one into input the language model can read.
  • Computed features. Beside each curve our code writes one or two numbers that it computes from that same curve, as a short sentence. They are measurements of the curve.
Computed featureWhat it measuresWhat the model reads
Largest changehow far the curve moves, against a quiet stretch of the same loop"its largest change is 0.5 times its usual quiet change"
Largest one-second stepthe biggest jump from one second to the next, and when it happens"its largest one-second step is 5.8 times its usual one, at second 243"
Controller check, boiler pressure onlywhether the valve moves the way the controller would"for 54 seconds it moves the opposite way to what the controller would do"

Computed features are not labels. Code computes them from the same 300 seconds the model reads. It never sees whether the window is an attack. Gradient boosting works on computed features only: seven per curve, plus a few that compare the curves. Our model reads the curve as well. The dated result records still call them "hints".

What the model writes. A sentence or two on how the curves move. For an attack, it adds the second the change starts. It ends with attack or normal.

One real window: the curves and their computed features go in, a verdict and a sentence come out.

In: 300 seconds of the boiler-level loop

In: the feature line code wrote for each signal

    Out: the model's answer

    A window from the check set. Answer: the seven-model vote. Source: HAI dataset, CC BY-SA 4.0.

    A design and a run. A design is one recipe: how each curve is turned into numbers, which computed features sit beside it, and how many attack examples the model sees. A run trains one model from one design. It shows the model every training window four times, takes about 67 minutes on one eighth of a rented graphics card and costs under 1 dollar.

    The search. We ran 64 runs in 8 rounds. We scored every run on the check set. During the search, no run touched the test set.

    Check-set score of every run, by round.

    Each dot is one run. Ringed dots are the seven runs of the feature-heavy design that vote. Lines mark gradient boosting on the check set. Perfect is 144. Source: run table of the search; HAI dataset, CC BY-SA 4.0.
    Show all 64 runs as a table

    What worked

    • Computed features beside the curves. Runs with them average 73.1. The same designs without added features average 56.5.
    • A better way to turn the curve into numbers. The design we started with scored 17 to 37 over five runs. Showing each curve against how much its loop normally moves, still without added features, scored 50 to 60 over four runs.
    • Using the model from the last pass. We scored the model after every pass in 8 runs. In all 8, the last pass scored best.

    What failed

    • More attack examples. With half of the training windows attacks, the score fell to −3.
    • A different starting point and a third computed feature. Neither gave a gain beyond the noise between repeats.

    One model is a gamble, so several vote. Train the same design again from a new random start, a repeat, and its score moves by up to 23 points. So repeats of one design vote, and the majority decides. We took two designs to the test set.

    DesignOne model, check setVoting, check set
    Simpler design71, 79, 78, 78three vote: 80
    Feature-heavy design63 to 86, eight repeatsseven vote: 90
    Gradient boosting82, or 87 when it reads the other loops

    Both designs give the model computed features. The simpler design gives each curve its largest change. The feature-heavy design gives each curve its largest one-second step and the second it happens. In the boiler pressure loop, both add the controller check.

    On the check set, seven models voting scored 90 and gradient boosting 82, or 87 when it reads the other loops. The lead did not hold on the test set.

    All scores on the 1,092 check windows. Bars show a range, dots single results. Source: HAI dataset, CC BY-SA 4.0.

    These check-set scores flatter us: we kept the designs that did best on that set. So before touching the test set, we wrote down the two designs, which models vote and how we score.

    Results: on the test set, gradient boosting scores 54 of 82. Our votes score 51 and 50.

    The test set holds 1,536 windows: 82 attack windows from 56 attacks, and 1,454 normal ones. Every model answered it once.

    Score on the test set, of a perfect 82.

    Score = caught − false alarms. Bars show the range over repeats, dots single repeats, the tick the mean. Source: HAI dataset, CC BY-SA 4.0.
    SystemAttack windows caught, of 82False alarms, of 1,454Score
    Gradient boosting711754
    Gradient boosting reading the other loops681454
    Our simpler design, three models voting661551
    Our feature-heavy design, seven models voting651550
    Our simpler design, one model, four repeats61 to 6813 to 2342 to 52, mean 47
    Our feature-heavy design, one model, eight repeats59 to 6412 to 2139 to 50, mean 45
    Range alarm38173−135
    • Voting helps on average. One model averages 45 to 47. Three voting score 51, seven score 50. The best single repeats also reach 52 and 50.
    • The check-set lead did not hold. Our seven-model vote went from 90 of 144 (63%) to 50 of 82 (61%). Gradient boosting went from 82 of 144 (57%) to 54 of 82 (66%).

    The gap is inside chance. Each 300-second stretch of the test recordings gives six windows, one per loop: 256 stretches in all. Gradient boosting and our three-model vote score differently on 29 of them: 16 go to gradient boosting, 13 to our vote. We also rebuilt the test set 20,000 times by drawing stretches at random. In nine of ten rebuilds the gap lies between −6 and +12 points. Our vote is level or ahead in about a third.

    Attacks found: gradient boosting and our two votes each find 50 to 52 of the 56 attacks.

    An attack counts as found when at least one of its windows is called attack. Source: HAI dataset, CC BY-SA 4.0.

    What our model also gives: the second and a sentence. Either vote names the start within 30 seconds for 30 of the 56 attacks. Always answering "second 108" gets 26. That beats a fixed guess, but not by much. Gradient boosting gives no start. We did not check how often the sentence is right.

    Attacks whose start the answer names within 30 seconds, of 56.

    Median error in brackets. Dashed line: always answering "second 108". Source: HAI dataset, CC BY-SA 4.0.

    Kimi K3.1 Pro. We asked Kimi K3.1 Pro, a much larger general-purpose model that was not trained on the plant, to judge 811 of the test windows: all 82 attack windows and half of the normal ones. It caught 78 of the 82 attack windows, but it called a third to a half of the normal windows attacks. It scores −181 when given our computed features and a few worked examples, and −284 without. On the same windows gradient boosting scores 63 and our votes 59 and 57.

    On the same 811 windows: attack windows caught, and false alarms.

    Each bar uses its own full scale: 82 attack windows left, 729 normal windows right. Source: HAI dataset, CC BY-SA 4.0.

    Cost. One of our models answers 1,000 windows for about 0.17 US dollars on a rented card. Three voting cost 0.50, seven cost 1.16. Kimi costs 1.54 to 1.64. With our model and with gradient boosting, the plant data can stay on site: our model also runs on a plain desktop processor, at about 3 seconds a window.

    What answering costs, per 1,000 windows, and where the plant data goes.

    Conclusions: seven models voting did not beat gradient boosting. They ended 4 points behind, a gap inside chance.

    Did seven models voting beat gradient boosting? No.

    On the test setAttack windows caught, of 82False alarms, of 1,454Score
    Gradient boosting711754
    Our seven models voting651550
    Difference6 fewer2 fewer4 behind

    The score counts both sides: attack windows caught, minus false alarms. Our seven models voting raised 2 fewer false alarms than gradient boosting. They also caught 6 fewer attack windows. That leaves them 4 points behind. Three models voting end 3 points behind: 66 caught, 15 false alarms, a score of 51.

    On the check set the order was the other way: 90 against 82. There the seven models caught 101 attack windows with 11 false alarms, and gradient boosting 108 with 26. That lead did not hold on the test set. A gap of 3 to 4 points is inside chance, so the fair reading is: about level on detection, with gradient boosting slightly ahead.

    1. Gradient boosting stays slightly ahead. It used default settings and trains in 5 seconds.
    2. Kimi K3.1 Pro, asked directly, raised far too many false alarms. On the same 811 windows it scores −181 and −284. Our votes score 59 and 57.
    3. Our model also gives a start second and a sentence. It names the start within 30 seconds for 30 of the 56 attacks. A fixed guess gets 26. We did not check how often the sentence is right. Gradient boosting gives neither.
    4. What we would try next, not tested here: let gradient boosting raise the alarm and let the language model explain it.

    What this does not show

    • The test set is not fully fresh. We scored earlier models and both comparisons on it before the search, and chose the starting design after seeing those scores. No choice made during the search used it. The two final designs answered it once, at the end.
    • 56 attacks are few, and they come from four recordings.
    • The model leans on the computed features. On the check set, one feature-heavy model makes 95 attack calls. With every curve blanked out it still makes 84. One simpler model goes from 99 to 72. With the seconds of the curve shuffled, the feature-heavy model makes 48. So it does read the curve, but the computed features carry most of the verdict. On the test set with the seconds shuffled, the feature-heavy design calls 395 to 677 of the 1,454 normal windows attack, because its computed feature then reports a large jump.

    Attack windows called attack, out of 144, with the curve normal, blank and shuffled.

    One model of the feature-heavy design, on the check set's 144 attack windows. The text stayed identical; only the curve changed. Source: HAI dataset, CC BY-SA 4.0.
    • The score depends on which repeats you get. Four repeats of the simpler design score 42, 52, 52 and 43 on the test set. The other three-model votes from the same four repeats score 52, 48 and 49.
    • Two kinds of attack stayed out of reach. On the check set, one of our votes missed 44 of the 144 attack windows. 36 of them fall in two groups: 24 water-level windows where the valve command did not jump, and the 12 boiler-temperature windows. Gradient boosting finds 9 of those 24.
    • The comparison with Kimi K3.1 Pro is not a contest of equals. Kimi got one prompt, ran without its step-by-step reasoning mode, and saw the curves as lists of numbers.
    • It is a research demo, not a deployed detector. HAI is a lab-scale plant with recorded attacks, not a live site.