Views
No views yet
models/DANN-BERT-Log-Anomaly-Detection/) - Domain-Adversarial Neural Networkmodels/LoRA-BERT-Log-Anomaly-Detection/) - Low-Rank Adaptationmodels/Hybrid-BERT-Log-Anomaly-Detection/) - BERT + Template Featuresmodels/XGBoost-Log-Anomaly-Detection/) - Gradient Boosting Classifier| Model | F1-Score (Macro) | Accuracy | Parameters |
|---|---|---|---|
| Hybrid-BERT | 92.8% | 94.3% | 110M |
| DANN-BERT | 90.3% | 92.1% | 110M |
| LoRA-BERT | 88.7% | 90.5% | 1.5M (trainable) |
| XGBoost | 88.5% | 91.2% | - |
1from huggingface_hub import hf_hub_download
2
3# Download BERT model
4model_path = hf_hub_download(
5 repo_id="krishnas4415/log-anomaly-detection-models",
6 filename="models/Hybrid-BERT-Log-Anomaly-Detection/pytorch_model.pt"
7)
8
9# Download XGBoost model
10xgb_path = hf_hub_download(
11 repo_id="krishnas4415/log-anomaly-detection-models",
12 filename="models/XGBoost-Log-Anomaly-Detection/best_mod.pkl"
13)1import torch
2import pickle
3from transformers import AutoTokenizer
4
5# Load BERT model
6model = torch.load(model_path)
7tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
8
9# Load XGBoost model
10with open(xgb_path, 'rb') as f:
11 xgb_model = pickle.load(f)
12
13# Example prediction
14log_text = "Apr 15 12:34:56 server sshd[1234]: Failed password for admin"
15inputs = tokenizer(log_text, return_tensors='pt', max_length=128, truncation=True, padding=True)
16
17with torch.no_grad():
18 outputs = model(**inputs)
19 predictions = torch.softmax(outputs.logits, dim=-1)
20 predicted_class = torch.argmax(predictions, dim=-1)1@misc{log-anomaly-detection-2024,
2 title={Log Anomaly Detection System},
3 author={Krishna Sharma},
4 year={2024},
5 url={https://github.com/krishnasharma4415/log-anomaly-detection}
6}