Instructions to use HagalazAI/BlueSecureBERT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HagalazAI/BlueSecureBERT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="HagalazAI/BlueSecureBERT")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("HagalazAI/BlueSecureBERT") model = AutoModelForSequenceClassification.from_pretrained("HagalazAI/BlueSecureBERT", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files24 unmodified lines252627282930311 unmodified line33343536373839403 unmodified lines44454647484950514 unmodified lines56575859606162632 unmodified lines66676869707172737475767778798081828384858624 unmodified lines> **Recommended cut-off:** `prob >= 0.579` (arg-max on the validation split)---## Intended uses & limits1 unmodified line* **Input language:** English* **No external test set** yet → treat numbers as optimistic---## Training data| Label | Rows |3 unmodified lines| Other | 130 000 || **Total** | **180 296** |---## Model details| Field | Value |4 unmodified lines| Hardware | 1× RTX 4090 (≈ 41 min) || Inference dtype| FP16-safe |---## Training Data License- **Source**: [trendmicro-ailab/Primus-FineWeb](https://huggingface.co/datasets/trendmicro-ailab/Primus-FineWeb)2 unmodified lines- Preserve all original copyright/license notices- Honor [Common Crawl ToU](https://commoncrawl.org/terms-of-use/)---## Quick start```pythonfrom transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizermodel_id = "HagalazAI/BlueSecureBERT"tok = AutoTokenizer.from_pretrained(model_id)model = AutoModelForSequenceClassification.from_pretrained(model_id)clf = pipeline("text-classification", model=model, tokenizer=tok, top_k=None)text = "Investigate potential SQL injection vulnerabilities."prob = clf(text)[0]["score"] # sigmoid prob for class 0 (Defensive)print(f"P(defensive) = {prob:.3f}")is_blue = prob >= 0.579 # ← recommended thresholdprint("is_blue:", is_blue)24 unmodified lines25262728293031323334353637381 unmodified line4041424344453 unmodified lines4950515253544 unmodified lines5960616263642 unmodified lines67686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412524 unmodified lines> **Recommended cut-off:** `prob >= 0.579` (arg-max on the validation split)## Demo| Phrase | Blue Score ||--------|------------|| To exfiltrate sensitive data, launch a phishing campaign that tricks employees into revealing their VPN credentials. | 0.066 || We should deploy an EDR solution, monitor all endpoints for intrusion attempts, and enforce strict password policies. | 0.557 || Our marketing team will unveil the new cybersecurity branding materials at next Tuesday’s antivirus product launch | 0.256 || I'm excited about the company picnic. There's no cybersecurity topic—just burgers and games. | 0.272 |## Intended uses & limits1 unmodified line* **Input language:** English* **No external test set** yet → treat numbers as optimistic## Training data| Label | Rows |3 unmodified lines| Other | 130 000 || **Total** | **180 296** |## Model details| Field | Value |4 unmodified lines| Hardware | 1× RTX 4090 (≈ 41 min) || Inference dtype| FP16-safe |## Training Data License- **Source**: [trendmicro-ailab/Primus-FineWeb](https://huggingface.co/datasets/trendmicro-ailab/Primus-FineWeb)2 unmodified lines- Preserve all original copyright/license notices- Honor [Common Crawl ToU](https://commoncrawl.org/terms-of-use/)## Quick start```pythonimport torchfrom transformers import AutoTokenizer, AutoModelForSequenceClassificationdef classify_texts(model_name, phrases, threshold=0.515):"""Returns a list of (probability_offensive, label) tuples for each phrasegiven a model_name and threshold."""tokenizer = AutoTokenizer.from_pretrained(model_name)model = AutoModelForSequenceClassification.from_pretrained(model_name)model.eval()inputs = tokenizer(phrases, padding=True, truncation=True, return_tensors="pt")with torch.no_grad():logits = model(**inputs).logits # shape: (batch_size, 2)probs_offensive = torch.softmax(logits, dim=1)[:, 1] # Probability of the "Offensive" classresults = []for p_val in probs_offensive:p_val = p_val.item()label = "Offensive (red-team)" if p_val >= threshold else "Not Offensive"results.append((p_val, label))return resultsdef main():# Example phrases: Offensive (red-team), Defensive (blue-team), Non-technicalphrases = [# 1) Cybersecurity Offensive / red-team"To exfiltrate sensitive data, launch a phishing campaign that tricks employees into revealing their VPN credentials.",# 2) Cybersecurity Defensive / blue-team"We should deploy an EDR solution, monitor all endpoints for intrusion attempts, and enforce strict password policies.",# 5) Cybersecruity Marketing"“Our marketing team will unveil the new cybersecurity branding materials at next Tuesday’s antivirus product launch",# 5) Non Cybersecruity related"I'm excited about the company picnic. There's no cybersecurity topic—just burgers and games."]# Classify with both modelsthreshold = 0.515blue_results = classify_texts("HagalazAI/BlueSecureBERT", phrases, threshold)red_results = classify_texts("HagalazAI/RedSecureBERT", phrases, threshold)# Print a Markdown tableprint("| # | Phrase | Blue Score | Blue Label | Red Score | Red Label |")print("|---|--------|-----------|-----------|----------|----------|")for i, text in enumerate(phrases, start=1):blue_score, blue_label = blue_results[i - 1]red_score, red_label = red_results[i - 1]print(f"| {i} | {text} | {blue_score:.3f} | {blue_label} | {red_score:.3f} | {red_label} |")if __name__ == "__main__":main()
README.md+61-22