Text Generation
Safetensors
English
code
unsloth
qwen2
cybersecurity
vulnerability-detection
cve
code-audit
code-repair
qwen2.5-coder
fine-sec
conversational
Instructions to use elsiddik/finsec_detector with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Local Apps Settings
- Unsloth Studio
How to use elsiddik/finsec_detector 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 elsiddik/finsec_detector 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 elsiddik/finsec_detector to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for elsiddik/finsec_detector to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="elsiddik/finsec_detector", max_seq_length=2048, )
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,3 +1,111 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: Qwen/Qwen2.5-Coder-7B-Instruct
|
| 4 |
+
library_name: unsloth
|
| 5 |
+
tags:
|
| 6 |
+
- cybersecurity
|
| 7 |
+
- vulnerability-detection
|
| 8 |
+
- cve
|
| 9 |
+
- code-audit
|
| 10 |
+
- code-repair
|
| 11 |
+
- qwen2.5-coder
|
| 12 |
+
- fine-sec
|
| 13 |
+
datasets:
|
| 14 |
+
- custom-sec-cve
|
| 15 |
+
language:
|
| 16 |
+
- en
|
| 17 |
+
- code
|
| 18 |
+
pipeline_tag: text-generation
|
| 19 |
---
|
| 20 |
+
|
| 21 |
+
# π‘οΈ FineSec-Detector: Specialized Security LLM (Qwen2.5-Coder-7B-Instruct)
|
| 22 |
+
|
| 23 |
+
**FineSec-Detector** is a 7B parameter specialized cybersecurity Large Language Model fine-tuned on high-precision CVE vulnerability reports, real-world exploit benchmarks, and secure code repair patterns using **Unsloth 4-bit QLoRA**.
|
| 24 |
+
|
| 25 |
+
The model acts as an automated Senior Application Security (AppSec) Auditor & Penetration Tester. It audits source code, identifies vulnerabilities, classifies severity & CWE IDs, and produces ready-to-merge secure code patches in structured JSON.
|
| 26 |
+
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
## β¨ Key Features
|
| 30 |
+
|
| 31 |
+
- π **Automated Vulnerability Detection**: Audits Python, C/C++, JavaScript, Go, PHP, Java, and Bash source code.
|
| 32 |
+
- π― **Structured JSON Output**: Produces standardized security reports suitable for CI/CD pipeline integration.
|
| 33 |
+
- π·οΈ **CWE & Severity Classification**: Classifies bugs into standard CWE categories (e.g., CWE-89 SQLi, CWE-79 XSS, CWE-78 RCE, CWE-120 Buffer Overflow) with CVSS-aligned severity levels (`CRITICAL`, `HIGH`, `MEDIUM`, `LOW`).
|
| 34 |
+
- π οΈ **Remediation & Patching**: Generates diffs and secure code refactors directly replacing vulnerable logic.
|
| 35 |
+
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
+
## π Quickstart: Inference
|
| 39 |
+
|
| 40 |
+
### 1. Using Unsloth (Fastest & Memory Efficient)
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
from unsloth import FastLanguageModel
|
| 44 |
+
|
| 45 |
+
# Load model and tokenizer
|
| 46 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 47 |
+
model_name = "elsiddik/finsec_detector",
|
| 48 |
+
max_seq_length = 1024,
|
| 49 |
+
load_in_4bit = True,
|
| 50 |
+
)
|
| 51 |
+
FastLanguageModel.for_inference(model)
|
| 52 |
+
|
| 53 |
+
# Security audit prompt
|
| 54 |
+
prompt = """### System Prompt:
|
| 55 |
+
You are FineSec-AI, an expert Application Security Engineer. Analyze code snippet for vulnerabilities and output JSON report with fields: 'vulnerabilities' (list of objects with severity, cwe, description, vulnerable_line, fix_code).
|
| 56 |
+
|
| 57 |
+
### Input Code:
|
| 58 |
+
```python
|
| 59 |
+
import sqlite3
|
| 60 |
+
|
| 61 |
+
def login(username, password):
|
| 62 |
+
conn = sqlite3.connect('users.db')
|
| 63 |
+
cursor = conn.cursor()
|
| 64 |
+
query = f"SELECT * FROM users WHERE username = '{username}' AND password = '{password}'"
|
| 65 |
+
cursor.execute(query)
|
| 66 |
+
return cursor.fetchone()
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
### Security Analysis (JSON):"""
|
| 70 |
+
|
| 71 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 72 |
+
outputs = model.generate(**inputs, max_new_tokens=512, use_cache=True)
|
| 73 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
---
|
| 77 |
+
|
| 78 |
+
## π Sample Output (Structured JSON)
|
| 79 |
+
|
| 80 |
+
```json
|
| 81 |
+
{
|
| 82 |
+
"is_vulnerable": true,
|
| 83 |
+
"severity": "CRITICAL",
|
| 84 |
+
"cwe": "CWE-89",
|
| 85 |
+
"vulnerability_type": "SQL Injection",
|
| 86 |
+
"description": "User input is directly concatenated into the SQL query string without parameterization, allowing unauthenticated SQL injection.",
|
| 87 |
+
"vulnerable_code": "query = f\"SELECT * FROM users WHERE username = '{username}' AND password = '{password}'\"",
|
| 88 |
+
"remediation": "Use parameterized SQL queries with placeholder parameters.",
|
| 89 |
+
"fixed_code": "query = 'SELECT * FROM users WHERE username = ? AND password = ?'\ncursor.execute(query, (username, password))"
|
| 90 |
+
}
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
---
|
| 94 |
+
|
| 95 |
+
## βοΈ Model Details
|
| 96 |
+
|
| 97 |
+
| Attribute | Details |
|
| 98 |
+
|---|---|
|
| 99 |
+
| **Base Architecture** | Qwen2.5-Coder-7B-Instruct |
|
| 100 |
+
| **Fine-Tuning Method** | QLoRA 4-bit (Unsloth) |
|
| 101 |
+
| **LoRA Target Modules** | `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj` |
|
| 102 |
+
| **LoRA Rank (r)** | 16 |
|
| 103 |
+
| **LoRA Alpha** | 32 |
|
| 104 |
+
| **Context Window** | 1024 tokens |
|
| 105 |
+
| **License** | Apache-2.0 |
|
| 106 |
+
|
| 107 |
+
---
|
| 108 |
+
|
| 109 |
+
## π Intended Use & Disclaimer
|
| 110 |
+
|
| 111 |
+
**FineSec-Detector** is designed for defensive security purposes, code auditing, secure code development, and AppSec integration. Users are responsible for exercising due diligence when integrating model output into production systems.
|