Downloads · 30 days
242
46% of all-time downloads
Reynier/moe-wordlist-dga-models
moe-wordlist-dga-models is a machine learning model from Reynier. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for keras. The card lists the license as mit.
[](https://huggingface.co/Reynier/moe-wordlist-dga-models) [](https://huggingface.co/Reynier/moe-wordlist-dga-models/tree/main/models) [](https://huggingface.co/Reynier/moe-wordlist-dga-models/tree/main/datasets)
Downloads · 30 days
242
46% of all-time downloads
All-time downloads
528
Public
Repo size
1.9 GB
Likes
1
Public
Click a slice to open those files.
.safetensors1.4 GB · 59%
From the Hugging Face model README
Systematic evaluation of seven expert models for detecting wordlist-based Domain Generation Algorithms (DGAs), identifying ModernBERT as the optimal expert achieving 86.7% F1-score on known families and 80.9% on unseen variants.
This repository contains the complete implementation of expert model evaluation for wordlist-based DGA detection, as described in our research paper (currently under review). Wordlist-based DGAs generate linguistically coherent domains that evade traditional detection methods, making them particularly challenging for cybersecurity systems.
| Model | Known F1 | Unknown F1 | Inference Time | Throughput |
|---|---|---|---|---|
| ModernBERT ⭐ | 86.7% | 80.9% | 26ms | 38 domains/s |
| Gemma 3 4B LoRA | 82.1% | 75.3% | 650ms | 1.5/s |
| LLaMA 3.2 3B LoRA | 81.4% | 74.8% | 680ms | 1.4/s |
| DomBertUrl | 81.2% | 84.6% | 28ms | 35/s |
| CNN | 78.9% | 72.1% | 15ms | 66/s |
| FANCI (RF) | 77.3% | 68.5% | <1ms | >100/s |
| LABin | 75.6% | 70.2% | 18ms | 55/s |
Key Improvement: Specialist training provides +9.4% F1-score improvement over generalist approaches on known families and +30.2% on unseen families.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load the optimal expert model
model_name = "Reynier/moe-wordlist-dga-models"
model_path = f"{model_name}/models/modernbert-wordlist-expert"
tokenizer = AutoTokenizer.from_pretrained("answerdotai/ModernBERT-base")
model = AutoModelForSequenceClassification.from_pretrained(
model_name,
subfolder="models/modernbert-wordlist-expert"
)
# Classify a domain
domain = "secure-banking-portal.com"
inputs = tokenizer(domain, return_tensors="pt", truncation=True, max_length=128)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)
print(f"Benign: {probs[0][0]:.4f}")
print(f"DGA: {probs[0][1]:.4f}")
# Clone the repository
git clone https://huggingface.co/Reynier/moe-wordlist-dga-models
cd moe-wordlist-dga-models
# Explore available models
ls models/
# Load datasets
python3 << EOF
import csv
with open('datasets/train_wl.csv', 'r') as f:
reader = csv.DictReader(f)
for i, row in enumerate(reader):
if i < 5:
print(row)
EOF
All models are located in models/ directory:
modernbert-wordlist-expert/ ⭐ (OPTIMAL)
answerdotai/ModernBERT-basemodernbert-generalist-54f/ (Baseline)
gemma-3-4b-lora/
google/gemma-3-4b-itllama-3.2-3b-lora/
meta-llama/Llama-3.2-3Bdombert-url/
cnn-wordlist/
fanci/
labin/
All datasets are in datasets/ directory:
train_wl.csv (160,000 samples)
domain,family,labeltrain_1M.csv (1,080,000 samples)
test-known/ (8 families)
.gz files (one per family)test-generalization/ (3 families)
.gz filesTraining and evaluation notebooks in notebooks/:
ModernBERT_base_DGA_Word.ipynb - Train ModernBERT expert (8 families)ModernBERT_base_DGA_54F.ipynb - Train ModernBERT generalist (54 families)Train_Gemma3_4B_DGA_WordList.ipynb - Fine-tune Gemma with LoRATrain_llama3B_DGA_WordList.ipynb - Fine-tune LLaMA with LoRATest_Gemma3_4B_DGA_Last.ipynb - Evaluate Gemma modelTest__llama3B_DGA.ipynb - Evaluate LLaMA modelDomUrlBert.ipynb - Train DomBertUrl modelCNN_Patron_WL.ipynb - Train CNN modelFANCI.ipynb - Train FANCI Random ForestLabin_wl.ipynb - Train LABin modelPhase 1: Known Families Performance
Phase 2: Generalization Capability
Training Families (8 wordlist-based):
Generalization Test (3 wordlist-based):
pip install torch transformers safetensors
pip install peft accelerate bitsandbytes
pip install scikit-learn joblib
pip install tensorflow keras
All experiments are fully reproducible:
datasets/ foldernotebooks/models/| Model | Known F1 | Unknown F1 |
|---|---|---|
| ModernBERT | 86.7% ± 3.0% | 80.9% ± 4.5% |
| Generalist | 79.2% ± 3.5% | 62.1% ± 5.2% |
This work is currently under review. Preliminary citation:
@article{leyva2025expert,
title={Expert Selection for Wordlist-Based DGA Detection: A Systematic Evaluation},
author={Leyva La O, Reynier and Catania, Carlos A. and Gonzalez, Rodrigo},
journal={Under Review},
year={2025}
}
This project is licensed under the MIT License - see LICENSE file for details.
Last Updated: October 2025