CoolFace
Modelpublic

krishnas4415/log-anomaly-detection-models

sourceHugging Facemitupdated 11mo agoView on Hugging Face
2likes
Model Card

Log Anomaly Detection Models

This repository contains trained models for the Log Anomaly Detection System that classifies system logs into 7 anomaly categories.

๐Ÿค– Available Models

BERT-based Models

  • โ€”DANN-BERT (models/DANN-BERT-Log-Anomaly-Detection/) - Domain-Adversarial Neural Network
  • โ€”LoRA-BERT (models/LoRA-BERT-Log-Anomaly-Detection/) - Low-Rank Adaptation
  • โ€”Hybrid-BERT (models/Hybrid-BERT-Log-Anomaly-Detection/) - BERT + Template Features

Traditional ML Models

  • โ€”XGBoost (models/XGBoost-Log-Anomaly-Detection/) - Gradient Boosting Classifier

๐Ÿ“Š Model Performance

ModelF1-Score (Macro)AccuracyParameters
Hybrid-BERT92.8%94.3%110M
DANN-BERT90.3%92.1%110M
LoRA-BERT88.7%90.5%1.5M (trainable)
XGBoost88.5%91.2%-

๐ŸŽฏ Classification Categories

  1. 1.Normal (0): Benign operations
  2. 2.Security Anomaly (1): Authentication failures, unauthorized access
  3. 3.System Failure (2): Crashes, kernel panics
  4. 4.Performance Issue (3): Timeouts, slow responses
  5. 5.Network Anomaly (4): Connection errors, packet loss
  6. 6.Config Error (5): Misconfigurations, invalid settings
  7. 7.Hardware Issue (6): Disk failures, memory errors

๐Ÿš€ Usage

Download Models

python
from huggingface_hub import hf_hub_download

# Download BERT model
model_path = hf_hub_download(
    repo_id="krishnas4415/log-anomaly-detection-models",
    filename="models/Hybrid-BERT-Log-Anomaly-Detection/pytorch_model.pt"
)

# Download XGBoost model
xgb_path = hf_hub_download(
    repo_id="krishnas4415/log-anomaly-detection-models", 
    filename="models/XGBoost-Log-Anomaly-Detection/best_mod.pkl"
)

Load and Use Models

python
import torch
import pickle
from transformers import AutoTokenizer

# Load BERT model
model = torch.load(model_path)
tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')

# Load XGBoost model
with open(xgb_path, 'rb') as f:
    xgb_model = pickle.load(f)

# Example prediction
log_text = "Apr 15 12:34:56 server sshd[1234]: Failed password for admin"
inputs = tokenizer(log_text, return_tensors='pt', max_length=128, truncation=True, padding=True)

with torch.no_grad():
    outputs = model(**inputs)
    predictions = torch.softmax(outputs.logits, dim=-1)
    predicted_class = torch.argmax(predictions, dim=-1)

๐Ÿ“š Training Data

  • โ€”Sources: 16 log types (Apache, SSH, Hadoop, HDFS, Linux, Windows, etc.)
  • โ€”Size: ~32,000 labeled logs
  • โ€”Classes: 7 anomaly categories
  • โ€”Features: BERT embeddings + template features + statistical features

๐Ÿ”— Related Links

๐Ÿ“„ Citation

bibtex
@misc{log-anomaly-detection-2024,
  title={Log Anomaly Detection System},
  author={Krishna Sharma},
  year={2024},
  url={https://github.com/krishnasharma4415/log-anomaly-detection}
}

๐Ÿ“ License

MIT License - see LICENSE file for details.