🔎 OpsLens-17M
Raw server log line in → structured incident JSON out. A 17M-parameter model trained from scratch on one laptop GPU. Runs on a CPU, fully offline.
Apache · OpenSSH · Linux · HDFS · OpenStack
What it does
Give it one log line. It returns the template, the variables, a severity, an anomaly flag, an incident tag, a one-sentence meaning, and up to three fix steps, with the line's real values filled in.
<|sys:OpenSSH|><|log|>Failed password for root from 183.62.140.253 port 38895 ssh2<|out|>
{"t":"Failed password for <*> from <*> port <*> ssh2",
"v":["root","183.62.140.253","38895"],
"s":"WARN", "a":1, "g":"ssh_bruteforce",
"m":"A wrong password was sent for real user root from 183.62.140.253.",
"f":["block 183.62.140.253 if failures are repeated","disable password login for root","enable fail2ban for sshd"]}
| Key | Meaning |
|---|---|
t | template (<*> marks variable slots) |
v | variables, copied byte-exact |
s | severity |
a | anomaly (0/1) |
g | incident tag |
m | plain-English meaning |
f | fix steps |
Quick start
from transformers import AutoTokenizer, AutoModelForCausalLM
repo = "viczx/opslens-17m"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo) # 65 MB, CPU is fine
line = "Failed password for root from 183.62.140.253 port 38895 ssh2" # message part, header stripped
ids = tok("<|sys:OpenSSH|><|log|>" + line + "<|out|>", return_tensors="pt").input_ids
out = model.generate(ids, max_new_tokens=256, do_sample=False, eos_token_id=4)
print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
Use greedy decoding. Pass only the message part of the line.
Results
Held-out test lines. Unseen = templates never trained on (15% of templates per system held out, seed 42).
| Metric | Seen | Unseen |
|---|---|---|
| Template exact match (PA) | 0.997 | 0.303 |
| Variables exact | 0.997 | 0.303 |
| Grouping accuracy | 1.000 | 0.595 |
| Anomaly F1 vs teacher | 1.00 (memorised) | 0.71 |
| Explanation + fix quality (1–5, LLM judge) | – | 2.16 |
Baseline, Drain + knowledge-base lookup: PA 0.355 seen / 0.352 unseen, and no explanation at all on unseen lines.
CPU latency (4 threads, fp32, OpsLens decoder): 100 ms p50 for known templates; about 1.1 s for new patterns, which decode the full explanation.
These numbers use the OpsLens decoder, which constrains the template to the input line with
<*>slots and copies variables byte-exact. Plain greedy decoding is simpler to set up but parses unseen templates worse.
Architecture
| Type | Decoder-only transformer, Llama-compatible (RMSNorm pre-norm, RoPE, SwiGLU, tied embeddings) |
| Layers / d_model / heads | 8 / 384 / 6 (head dim 64), MLP 1024 |
| Context | 512 trained (1024 positions supported) |
| Vocabulary | 7,527 byte-level BPE, digits split one per token, trained from scratch |
| Parameters | 17,052,672 |
| Size | 65 MB fp32 safetensors |
Training
- Pretraining: next-token prediction on 100M tokens of raw Loghub-2.0 lines (val loss 0.67).
- Fine-tuning: (line → JSON) pairs built from a 499-entry knowledge base written by a teacher model (Claude), plus copies with constant words swapped so the model learns to copy, not memorise.
- Hardware: one RTX 3050 Laptop GPU (4 GB), about 1.5 hours in total.
Part of OpsLens
The model is one stage of the OpsLens system:
normaliser → template cache → OpsLens-17M → knowledge-base grounding → rule-based incident graphs
Used alone, it gives the per-line JSON only.
Limitations
- Five log systems only. Other formats need retraining (a few hours on one GPU).
- On templates it hasn't seen, meanings and fixes are often wrong. The OpsLens UI marks those lines "low confidence, new pattern" and never presents their fixes as verified.
- Knowledge labels come from a larger teacher model and were not all checked by a human.
- It recommends; it never acts.
Licence & data
Code and weights: MIT. Data: Loghub-2.0 (Jiang et al., ISSTA 2024).