Instructions to use Ushitha/ushitha-coder-network-corrector with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Ushitha/ushitha-coder-network-corrector with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-7B-Instruct") model = PeftModel.from_pretrained(base_model, "Ushitha/ushitha-coder-network-corrector") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,27 +1,31 @@
|
|
| 1 |
---
|
| 2 |
base_model: Qwen/Qwen2.5-7B-Instruct
|
| 3 |
tags:
|
| 4 |
-
- network-security
|
| 5 |
-
- cisco
|
| 6 |
-
- router
|
| 7 |
-
-
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
-
|
|
|
|
| 11 |
license: apache-2.0
|
| 12 |
---
|
| 13 |
|
| 14 |
# Network Security Config LoRA
|
| 15 |
|
| 16 |
-
Fine-tuned LoRA adapter on
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
## What it does
|
| 19 |
|
| 20 |
-
|
| 21 |
-
1.
|
| 22 |
-
2.
|
| 23 |
-
3.
|
| 24 |
-
4.
|
| 25 |
|
| 26 |
## Usage
|
| 27 |
|
|
@@ -30,29 +34,40 @@ from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
| 30 |
from peft import PeftModel
|
| 31 |
import torch
|
| 32 |
|
| 33 |
-
base
|
| 34 |
-
|
| 35 |
|
| 36 |
tokenizer = AutoTokenizer.from_pretrained(base)
|
| 37 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
messages = [
|
| 41 |
-
{"role": "system",
|
| 42 |
-
{"role": "user",
|
| 43 |
]
|
| 44 |
-
text
|
| 45 |
inputs = tokenizer(text, return_tensors="pt").to(model.device)
|
| 46 |
-
|
| 47 |
-
print(tokenizer.decode(
|
| 48 |
```
|
| 49 |
|
| 50 |
-
## Training
|
| 51 |
|
| 52 |
| Parameter | Value |
|
| 53 |
|-----------|-------|
|
| 54 |
| Base model | `Qwen/Qwen2.5-7B-Instruct` |
|
| 55 |
| Technique | QLoRA 4-bit NF4 |
|
| 56 |
-
| LoRA rank | 16 /
|
| 57 |
-
|
|
|
|
|
|
|
|
| 58 |
| Learning rate | 0.0002 |
|
|
|
|
|
|
| 1 |
---
|
| 2 |
base_model: Qwen/Qwen2.5-7B-Instruct
|
| 3 |
tags:
|
| 4 |
+
- network-security
|
| 5 |
+
- cisco
|
| 6 |
+
- router
|
| 7 |
+
- switch
|
| 8 |
+
- lora
|
| 9 |
+
- peft
|
| 10 |
+
- qlora
|
| 11 |
+
- qwen2.5
|
| 12 |
license: apache-2.0
|
| 13 |
---
|
| 14 |
|
| 15 |
# Network Security Config LoRA
|
| 16 |
|
| 17 |
+
Fine-tuned LoRA adapter on [Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct).
|
| 18 |
+
|
| 19 |
+
Trained on **246 Cisco router/switch configuration pairs** across 10 categories:
|
| 20 |
+
Basic Router, Basic Switch, VLAN, ACL, Trunking, NAT, OSPF, EIGRP, DHCP, SSH/Telnet.
|
| 21 |
|
| 22 |
## What it does
|
| 23 |
|
| 24 |
+
Give it an insecure or AI-generated Cisco config — it will:
|
| 25 |
+
1. Identify every security vulnerability (Critical / Important / Best-Practice)
|
| 26 |
+
2. Explain why each issue matters
|
| 27 |
+
3. Output a fully corrected, production-hardened configuration
|
| 28 |
+
4. Show the security score improvement
|
| 29 |
|
| 30 |
## Usage
|
| 31 |
|
|
|
|
| 34 |
from peft import PeftModel
|
| 35 |
import torch
|
| 36 |
|
| 37 |
+
base = "Qwen/Qwen2.5-7B-Instruct"
|
| 38 |
+
lora_repo = "Ushitha/ushitha-coder-network-corrector"
|
| 39 |
|
| 40 |
tokenizer = AutoTokenizer.from_pretrained(base)
|
| 41 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 42 |
+
base, torch_dtype=torch.bfloat16, device_map="auto")
|
| 43 |
+
model = PeftModel.from_pretrained(model, lora_repo)
|
| 44 |
+
|
| 45 |
+
insecure_config = """
|
| 46 |
+
hostname Router
|
| 47 |
+
interface GigabitEthernet0/0
|
| 48 |
+
ip address 192.168.1.1 255.255.255.0
|
| 49 |
+
no shutdown
|
| 50 |
+
"""
|
| 51 |
|
| 52 |
messages = [
|
| 53 |
+
{"role": "system", "content": "You are a network security expert..."},
|
| 54 |
+
{"role": "user", "content": f"Review this config:\n{insecure_config}"},
|
| 55 |
]
|
| 56 |
+
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 57 |
inputs = tokenizer(text, return_tensors="pt").to(model.device)
|
| 58 |
+
output = model.generate(**inputs, max_new_tokens=2048, temperature=0.1, do_sample=True)
|
| 59 |
+
print(tokenizer.decode(output[0], skip_special_tokens=True))
|
| 60 |
```
|
| 61 |
|
| 62 |
+
## Training Details
|
| 63 |
|
| 64 |
| Parameter | Value |
|
| 65 |
|-----------|-------|
|
| 66 |
| Base model | `Qwen/Qwen2.5-7B-Instruct` |
|
| 67 |
| Technique | QLoRA 4-bit NF4 |
|
| 68 |
+
| LoRA rank / alpha | 16 / 32 |
|
| 69 |
+
| Training examples | 246 |
|
| 70 |
+
| Epochs | 3 |
|
| 71 |
+
| Effective batch size | 8 |
|
| 72 |
| Learning rate | 0.0002 |
|
| 73 |
+
| Hardware | NVIDIA A40 48 GB |
|