ChronusQLAdvanced analysis

Temporal ML and LLM models

Align streams in event time, derive features and labels, train online models, and project predictions as the stream evolves.

Advanced analysis

14 min read

Language reference

A temporal model is a query pipeline

Execution sketchAlign, learn, predict
timestampedInputs
WITHINAlign
windowedFeatures
online / LLMModel
predictionCompute
ChronusQL keeps data alignment, feature construction, model definition, and output computation in one auditable statement.
  1. 01
    Timestamp inputs

    Every participating stream declares its event-time field.

  2. 02
    Align streams

    Optional `ALIGN JOIN` clauses match nearby records within a bounded tolerance.

  3. 03
    Partition and window

    Keys and temporal context isolate model state.

  4. 04
    Build features

    Field, difference, average, count, standard deviation, and z-score features are declared explicitly.

  5. 05
    Define supervision

    Classifiers use `LABELS`; regressors use `TARGET`; `FUTURE` creates bounded forward labels.

  6. 06
    Compute results

    Project classifications, probabilities, confidence, predictions, residuals, or extracted values.

Online classifier and regressor

Online classifier with aligned inputChronusQL
SELECT c.device_id, predicted_label, confidence
INTO output
FROM cpu AS c TIMESTAMP BY c.ts
ALIGN JOIN memory AS m TIMESTAMP BY m.ts
  ON c.device_id = m.device_id
  WITHIN Duration(second, 5)
ANCHOR c
PARTITION BY c.device_id
WINDOW BY SlidingWindow(Duration(minute, 30))
FEATURES
  cpu_value = c.cpu,
  memory_value = m.memory
LABELS
  impact = FUTURE(c.latency > 500, Duration(second, 10)),
  normal = c.cpu < 60 AND m.memory < 70
MODEL incident = TRAIN ONLINE_CLASSIFIER()
LABELS impact, normal
WITH (min_examples = 20)
COMPUTE
  predicted_label = CLASSIFY(incident),
  confidence = PROBABILITY(incident)
Online regressorChronusQL
SELECT p.device_id, prediction, residual
INTO output
FROM readings AS p TIMESTAMP BY p.ts
PARTITION BY p.device_id
WINDOW BY SlidingWindow(Duration(minute, 30))
FEATURES
  current_value = p.value,
  value_delta = DIFF(p.value),
  window_mean = AVG(p.value)
MODEL forecast = TRAIN ONLINE_REGRESSOR()
TARGET p.next_value
WITH (min_examples = 4)
COMPUTE
  prediction = PREDICT(forecast),
  residual = RESIDUAL(forecast)

Feature and output functions

ContextFunctions
FeaturesField expression, DIFF, AVG, MEAN, COUNT, STDDEV, ZSCORE
LabelsBoolean condition or FUTURE(condition, Duration(...))
Classifier outputCLASSIFY, PROBABILITY, CONFIDENCE
Regressor outputPREDICT, RESIDUAL
LLM outputCLASSIFY, CONFIDENCE, or EXTRACT according to task

Bounded LLM classification and extraction

Classify a text featureChronusQL
SELECT category, confidence
INTO output
FROM logs AS l TIMESTAMP BY l.ts
FEATURES text = l.message
MODEL classifier = LLM(
  TASK 'classify',
  INPUT text,
  LABELS ('normal', 'alert'),
  PROVIDER 'default'
)
COMPUTE
  category = CLASSIFY(classifier),
  confidence = CONFIDENCE(classifier)
Extract a structured valueChronusQL
SELECT extracted
INTO output
FROM logs AS l TIMESTAMP BY l.ts
FEATURES text = l.message
MODEL extraction = LLM(
  TASK 'extract',
  INPUT text,
  SCHEMA '{"value":"string"}',
  PROVIDER 'default'
)
COMPUTE extracted = EXTRACT(extraction)