Ushitha commited on
Commit
72d3038
·
verified ·
1 Parent(s): 27cf552

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +40 -25
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-config
7
- - lora
8
- - peft
9
- - qlora
10
- - qwen2.5
 
11
  license: apache-2.0
12
  ---
13
 
14
  # Network Security Config LoRA
15
 
16
- Fine-tuned LoRA adapter on top of [Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct).
 
 
 
17
 
18
  ## What it does
19
 
20
- Given a router/switch configuration, this model:
21
- 1. Reasons step-by-step through all security vulnerabilities
22
- 2. Identifies misconfigurations with severity labels (CRITICAL / HIGH / MEDIUM)
23
- 3. Outputs a fully corrected, hardened configuration
24
- 4. Summarises the most important changes and shows before/after security scores
25
 
26
  ## Usage
27
 
@@ -30,29 +34,40 @@ from transformers import AutoTokenizer, AutoModelForCausalLM
30
  from peft import PeftModel
31
  import torch
32
 
33
- base = "Qwen/Qwen2.5-7B-Instruct"
34
- lora = "Ushitha/ushitha-coder-network-corrector"
35
 
36
  tokenizer = AutoTokenizer.from_pretrained(base)
37
- model = AutoModelForCausalLM.from_pretrained(base, torch_dtype=torch.bfloat16, device_map="auto")
38
- model = PeftModel.from_pretrained(model, lora)
 
 
 
 
 
 
 
 
39
 
40
  messages = [
41
- {"role": "system", "content": "You are a network security expert..."},
42
- {"role": "user", "content": "Review this config:\n\n```\nhostname Router\n...\n```"},
43
  ]
44
- text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
45
  inputs = tokenizer(text, return_tensors="pt").to(model.device)
46
- out = model.generate(**inputs, max_new_tokens=2048, temperature=0.1)
47
- print(tokenizer.decode(out[0], skip_special_tokens=True))
48
  ```
49
 
50
- ## Training details
51
 
52
  | Parameter | Value |
53
  |-----------|-------|
54
  | Base model | `Qwen/Qwen2.5-7B-Instruct` |
55
  | Technique | QLoRA 4-bit NF4 |
56
- | LoRA rank | 16 / alpha 32 |
57
- | Epochs | 20 |
 
 
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 |