File size: 1,728 Bytes
fde1d7e
d1ae10b
 
 
 
 
 
 
 
 
 
fde1d7e
 
d1ae10b
fde1d7e
d1ae10b
fde1d7e
d1ae10b
fde1d7e
d1ae10b
 
 
 
 
fde1d7e
d1ae10b
fde1d7e
d1ae10b
 
 
 
fde1d7e
d1ae10b
 
fde1d7e
d1ae10b
 
 
fde1d7e
d1ae10b
 
 
 
 
 
 
 
 
fde1d7e
d1ae10b
fde1d7e
d1ae10b
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---
base_model: Qwen/Qwen2.5-7B-Instruct
tags:
  - network-security
  - cisco
  - router-config
  - lora
  - peft
  - qlora
  - qwen2.5
license: apache-2.0
---

# Network Security Config LoRA

Fine-tuned LoRA adapter on top of [Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct).

## What it does

Given a router/switch configuration, this model:
1. Reasons step-by-step through all security vulnerabilities
2. Identifies misconfigurations with severity labels (CRITICAL / HIGH / MEDIUM)
3. Outputs a fully corrected, hardened configuration
4. Summarises the most important changes and shows before/after security scores

## Usage

```python
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch

base = "Qwen/Qwen2.5-7B-Instruct"
lora = "Ushitha/ushitha-coder-network-corrector"

tokenizer = AutoTokenizer.from_pretrained(base)
model = AutoModelForCausalLM.from_pretrained(base, torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(model, lora)

messages = [
    {"role": "system", "content": "You are a network security expert..."},
    {"role": "user",   "content": "Review this config:\n\n```\nhostname Router\n...\n```"},
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=2048, temperature=0.1)
print(tokenizer.decode(out[0], skip_special_tokens=True))
```

## Training details

| Parameter | Value |
|-----------|-------|
| Base model | `Qwen/Qwen2.5-7B-Instruct` |
| Technique | QLoRA 4-bit NF4 |
| LoRA rank | 16 / alpha 32 |
| Epochs | 20 |
| Learning rate | 0.0002 |