Text Generation
Transformers
Safetensors
English
mistral
text-generation-inference
unsloth
cybersecurity
threat-intelligence
cve
conversational
Instructions to use vanshkamra12/CyberSecurity-Model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use vanshkamra12/CyberSecurity-Model with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="vanshkamra12/CyberSecurity-Model") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("vanshkamra12/CyberSecurity-Model") model = AutoModelForCausalLM.from_pretrained("vanshkamra12/CyberSecurity-Model") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use vanshkamra12/CyberSecurity-Model with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "vanshkamra12/CyberSecurity-Model" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vanshkamra12/CyberSecurity-Model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/vanshkamra12/CyberSecurity-Model
- SGLang
How to use vanshkamra12/CyberSecurity-Model with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "vanshkamra12/CyberSecurity-Model" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vanshkamra12/CyberSecurity-Model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "vanshkamra12/CyberSecurity-Model" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vanshkamra12/CyberSecurity-Model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio new
How to use vanshkamra12/CyberSecurity-Model with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for vanshkamra12/CyberSecurity-Model to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for vanshkamra12/CyberSecurity-Model to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for vanshkamra12/CyberSecurity-Model to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="vanshkamra12/CyberSecurity-Model", max_seq_length=2048, ) - Docker Model Runner
How to use vanshkamra12/CyberSecurity-Model with Docker Model Runner:
docker model run hf.co/vanshkamra12/CyberSecurity-Model
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# 🛡️ CyberThreat Intel LLM (Phi-3-mini Fine-Tuned)
|
|
|
|
| 2 |
This is a fine-tuned version of Microsoft's **Phi-3-mini-4k-instruct**, optimized specifically to act as a Cybersecurity Threat Analyst. It takes raw CVE vulnerability data and generates professional, structured threat intelligence reports.
|
|
|
|
| 3 |
**▶️ Try the Live Demo:** [CyberThreat Intel Analyzer (Hugging Face Space)](https://huggingface.co/spaces/vanshkamra12/CyberThreat-Intel-Analyzer)
|
|
|
|
| 4 |
**💻 Code & Dataset:** [GitHub Repository](https://github.com/vanshkamra12/CyberThreat-Intel-LLM)
|
|
|
|
| 5 |
---
|
|
|
|
| 6 |
## 🎯 What it does
|
|
|
|
| 7 |
Feed the model a raw CVE description, CVSS score, and vendor, and it will generate a comprehensive report including:
|
| 8 |
- **Executive Summary** (Plain English explanation)
|
| 9 |
- **Technical Analysis** (Vectors, complexity, privileges)
|
|
@@ -12,33 +33,43 @@ Feed the model a raw CVE description, CVSS score, and vendor, and it will genera
|
|
| 12 |
- **Risk Assessment**
|
| 13 |
- **Remediation Steps**
|
| 14 |
- **Detection Rules** (YARA/Sigma)
|
|
|
|
| 15 |
## 🧠 Model Details
|
| 16 |
- **Base Model:** `Phi-3-mini-4k-instruct` (3.8B parameters)
|
| 17 |
- **Training Method:** QLoRA (4-bit quantization) with Unsloth
|
| 18 |
- **Trainable Parameters:** 29.8M (0.78% of total)
|
| 19 |
- **Training Data:** 471 synthetic instruction-tuning pairs generated using Llama 3.1 8B from raw NIST NVD CVE data.
|
| 20 |
- **Final Training Loss:** 0.337
|
|
|
|
| 21 |
## 🚀 How to use in Python
|
|
|
|
| 22 |
```python
|
| 23 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 24 |
import torch
|
|
|
|
| 25 |
model_id = "vanshkamra12/CyberSecurity-Model"
|
|
|
|
| 26 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 27 |
model = AutoModelForCausalLM.from_pretrained(
|
| 28 |
model_id,
|
| 29 |
torch_dtype=torch.float16,
|
| 30 |
device_map="auto"
|
| 31 |
)
|
|
|
|
| 32 |
prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
|
|
|
| 33 |
### Instruction:
|
| 34 |
Analyze the following vulnerability data and produce a structured threat intelligence report.
|
|
|
|
| 35 |
### Input:
|
| 36 |
CVE ID: CVE-2024-21762
|
| 37 |
Description: A out-of-bound write vulnerability in FortiOS SSL VPN allows a remote unauthenticated attacker to execute arbitrary code or commands via specially crafted HTTP requests.
|
| 38 |
CVSS Score: 9.8 CRITICAL
|
| 39 |
Vendor: Fortinet
|
|
|
|
| 40 |
### Response:
|
| 41 |
"""
|
|
|
|
| 42 |
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 43 |
outputs = model.generate(**inputs, max_new_tokens=1000, temperature=0.7)
|
| 44 |
-
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
|
|
|
| 1 |
+
---
|
| 2 |
+
base_model: unsloth/Phi-3-mini-4k-instruct-bnb-4bit
|
| 3 |
+
tags:
|
| 4 |
+
- text-generation-inference
|
| 5 |
+
- transformers
|
| 6 |
+
- unsloth
|
| 7 |
+
- mistral
|
| 8 |
+
- cybersecurity
|
| 9 |
+
- threat-intelligence
|
| 10 |
+
- cve
|
| 11 |
+
license: apache-2.0
|
| 12 |
+
language:
|
| 13 |
+
- en
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
# 🛡️ CyberThreat Intel LLM (Phi-3-mini Fine-Tuned)
|
| 17 |
+
|
| 18 |
This is a fine-tuned version of Microsoft's **Phi-3-mini-4k-instruct**, optimized specifically to act as a Cybersecurity Threat Analyst. It takes raw CVE vulnerability data and generates professional, structured threat intelligence reports.
|
| 19 |
+
|
| 20 |
**▶️ Try the Live Demo:** [CyberThreat Intel Analyzer (Hugging Face Space)](https://huggingface.co/spaces/vanshkamra12/CyberThreat-Intel-Analyzer)
|
| 21 |
+
|
| 22 |
**💻 Code & Dataset:** [GitHub Repository](https://github.com/vanshkamra12/CyberThreat-Intel-LLM)
|
| 23 |
+
|
| 24 |
---
|
| 25 |
+
|
| 26 |
## 🎯 What it does
|
| 27 |
+
|
| 28 |
Feed the model a raw CVE description, CVSS score, and vendor, and it will generate a comprehensive report including:
|
| 29 |
- **Executive Summary** (Plain English explanation)
|
| 30 |
- **Technical Analysis** (Vectors, complexity, privileges)
|
|
|
|
| 33 |
- **Risk Assessment**
|
| 34 |
- **Remediation Steps**
|
| 35 |
- **Detection Rules** (YARA/Sigma)
|
| 36 |
+
|
| 37 |
## 🧠 Model Details
|
| 38 |
- **Base Model:** `Phi-3-mini-4k-instruct` (3.8B parameters)
|
| 39 |
- **Training Method:** QLoRA (4-bit quantization) with Unsloth
|
| 40 |
- **Trainable Parameters:** 29.8M (0.78% of total)
|
| 41 |
- **Training Data:** 471 synthetic instruction-tuning pairs generated using Llama 3.1 8B from raw NIST NVD CVE data.
|
| 42 |
- **Final Training Loss:** 0.337
|
| 43 |
+
|
| 44 |
## 🚀 How to use in Python
|
| 45 |
+
|
| 46 |
```python
|
| 47 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 48 |
import torch
|
| 49 |
+
|
| 50 |
model_id = "vanshkamra12/CyberSecurity-Model"
|
| 51 |
+
|
| 52 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 53 |
model = AutoModelForCausalLM.from_pretrained(
|
| 54 |
model_id,
|
| 55 |
torch_dtype=torch.float16,
|
| 56 |
device_map="auto"
|
| 57 |
)
|
| 58 |
+
|
| 59 |
prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
| 60 |
+
|
| 61 |
### Instruction:
|
| 62 |
Analyze the following vulnerability data and produce a structured threat intelligence report.
|
| 63 |
+
|
| 64 |
### Input:
|
| 65 |
CVE ID: CVE-2024-21762
|
| 66 |
Description: A out-of-bound write vulnerability in FortiOS SSL VPN allows a remote unauthenticated attacker to execute arbitrary code or commands via specially crafted HTTP requests.
|
| 67 |
CVSS Score: 9.8 CRITICAL
|
| 68 |
Vendor: Fortinet
|
| 69 |
+
|
| 70 |
### Response:
|
| 71 |
"""
|
| 72 |
+
|
| 73 |
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 74 |
outputs = model.generate(**inputs, max_new_tokens=1000, temperature=0.7)
|
| 75 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|