Views
No views yet
bert-base-uncased and trained to perform token classification on log messages. It extracts structured attributes (service, level, event, error_code, user_id, ip, etc.) from unstructured log text using a BIO tagging scheme.bert-large-uncased| Field | Description |
|---|---|
| service | Application or service name (e.g., "auth", "api") |
| level | Log level (e.g., "info", "error", "warn") |
| timestamp | Timestamp or date reference |
| environment | Deployment environment (e.g., "prod", "staging") |
| event | Event type or action (e.g., "login", "request") |
| error_message | Human-readable error message |
| status_code | HTTP or service status code |
| duration | Duration |
| ip | IP address (client or server) |
| method | HTTP method (GET, POST, etc.) |
| path | URL path or resource path |
| useragent | User-Agent header |
| hostname | Server hostname |
pip install transformers torch1from transformers import AutoTokenizer, AutoModelForTokenClassification
2import torch
3model_name = "Aliph0th/logtheus-ml"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForTokenClassification.from_pretrained(model_name)
6text = "[auth] failed login for user 123 from 10.1.2.3 code=E401"
7# Tokenize and forward pass
8inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
9outputs = model(**inputs)
10logits = outputs.logits
11# Get predicted label IDs
12predicted_ids = torch.argmax(logits, dim=-1)
13# Map back to label names
14id2label = model.config.id2label
15predictions = [[id2label[int(p)] for p in pred] for pred in predicted_ids]
16print(predictions)attributes: High-confidence extractions (dict of canonical_field → value)low_confidence_attributes: Below-threshold extractionsattribute_confidence: Per-field confidence scoresmessage: Original log textconfidence: Overall prediction confidence (0-1)model_version: Model version string{"id":"1","text":"[auth] failed login for user 123 from 10.1.2.3","entities":[{"start":1,"end":5,"label":"service"},{"start":28,"end":32,"label":"user_id"},{"start":38,"end":46,"label":"ip"}]}text: Raw log line (string)entities: List of entity annotations
start, end: Character-level offsets in text (0-indexed)label: Canonical field name1# 1. Prepare raw log files (deduplicate, split train/val)
2python scripts/process_data.py data/annotated/ --p 0.8
3# 2. Train model
4python training/train_token_classifier.py \
5 --train-file data/train.jsonl \
6 --val-file data/val.jsonl \
7 --output-dir artifacts/model_v1 \
8 --base-model bert-base-uncased \
9 --epochs 5 \
10 --batch-size 16