Downloads · 30 days
0
ondrejspilka/anomalyBert
anomalyBert is a time series forecasting model from ondrejspilka. Use it for the time series forecasting task on the model card, and read the license before you ship it in a product. It is set up for onnxruntime. The card lists the license as mit.
Encoder-only transformer for anomaly detection in univariate timeseries data. Exported as ONNX for lightweight inference without PyTorch.
Downloads · 30 days
0
Access
Public
Updated Feb 20, 2026
Repo size
460 KB
Likes
0
Public
Click a slice to open those files.
.png183 KB · 56%
From the Hugging Face model README
Encoder-only transformer for anomaly detection in univariate timeseries data. Exported as ONNX for lightweight inference without PyTorch.

(timestamp, value) pairs[0, 1]Normalized values → Sliding Window (size=16, stride=1)
→ ValueEmbedding: Linear(1 → 64)
→ Sinusoidal Positional Encoding
→ Transformer Encoder (2 layers, 4 heads, d_ff=128)
→ AnomalyScoringHead: MLP → Sigmoid
→ Overlapping Window Aggregation → Top-N
import numpy as np
import json
import onnxruntime as ort
# Load model and metadata
session = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
meta = json.load(open("model.onnx.json"))
# Normalize input (using saved min/max from metadata)
norm = meta["normalizer"]
values = np.array([...], dtype=np.float32)
normalized = (values - norm["min"]) / (norm["max"] - norm["min"])
# Run inference on a window
window = normalized[:16].reshape(1, -1).astype(np.float32)
scores = session.run(None, {"input": window})[0]
pip install -e ".[onnx]"
anomalybert detect --model model.onnx --input data.csv --top-n 10
from anomalybert.inference.onnx_detector import OnnxAnomalyDetector
detector = OnnxAnomalyDetector("model.onnx")
results = detector.detect(timestamps, values, top_n=10)
| File | Description |
|---|---|
model.onnx | ONNX model graph and weights |
model.onnx.json | Model config and normalizer parameters |
Trained on 8 synthetic anomaly scenarios: point anomaly, contextual anomaly, collective anomaly, seasonal with anomaly, trend shift, noise burst, frequency change, and flat signal. Each scenario generates randomized timeseries with labeled anomaly positions and probabilities.
GitHub: anomalyBert