How to use from
SGLang
# Gated model: Login with a HF token with gated access permission
hf auth login
Install from pip and serve model
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
    --model-path "ProKope-AI/ProKope-SecAudit-4B" \
    --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": "ProKope-AI/ProKope-SecAudit-4B",
		"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 "ProKope-AI/ProKope-SecAudit-4B" \
        --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": "ProKope-AI/ProKope-SecAudit-4B",
		"messages": [
			{
				"role": "user",
				"content": "What is the capital of France?"
			}
		]
	}'
Quick Links

Request Access to ProKope-SecAudit-4B

Access requests are reviewed manually by ProKope AI. Weights and configurations are distributed under the Apache-2.0 license with clean-room permissive upstream provenance for self-hosted security auditing, research, and commercial integration.

By requesting access to ProKope-SecAudit-4B, you acknowledge that access requests are reviewed by ProKope AI, that use of the released model weights is governed by the Apache License 2.0 in the repository LICENSE file, and that model verdicts must be paired with static/test verification gates rather than relied upon as a standalone security boundary.

Log in or Sign Up to review the conditions and access this model content.

ProKope-SecAudit-4B™

ProKope-SecAudit-4B™ is a 4.02B-parameter (bfloat16) code security auditing and CWE remediation model built by ProKope AI™ from Qwen/Qwen3-4B-Instruct-2507 (Apache-2.0) to inspect source code snippets and pull-request diffs, emit structured vulnerability triage JSON (vulnerable, cwe_id, severity, taint_flow, root_cause), and propose minimal fixed_code patches.


Model Specifications

Specification Value
Architecture Qwen3ForCausalLM (36 layers, 32 Q heads / 8 KV heads, hidden_size = 2560)
Parameters & Precision 4,022,468,096 (4.02B), exported as bfloat16 (5 shards <= 1.80 GB, 8.04 GB total)
Context Window 262,144 base max_position_embeddings; fine-tuned at max_len = 1,536 (0 test rows > 1,536)
Fine-Tuning Method NF4 4-bit QLoRA (r = 32, lora_alpha = 64, dropout = 0.05, attention + MLP projections), assistant-only masking
Upstream Corpus (Clean-Room) hitoshura25/cvefixes (Apache-2.0), ismailtasdelen/SecureCodePairs (MIT), colin/PrimeVul (MIT)
Class & Decontamination Controls 50/50 vulnerable/safe pairing per source (train = 2,088, val = 404, test = 500); 0 exact duplicates & 0 8-gram/13-gram overlap
Training Language Mix (n = 2,088) C (1,198 / 57.4%), C++ (190 / 9.1%), Ruby (106), PHP (106), JS (88), Go (80), Java (66), Python (64), TS (44), C# (40), other (106)
Test Split Language Mix (n = 500) C (136), Go (62), Ruby (50), PHP (40), Python (40), Java (36), JS (26), C++ (26), Scala (20), TS (16), other (48)
Default Decoding Greedy ("do_sample": false in generation_config.json, max_new_tokens = 768)
License & Gating apache-2.0 (LICENSE), gated: manual

Output JSON Contract & Sample Output

Every request uses a label-neutral prompt (non_unique_findings = 0) and returns structured JSON with exact keys:

Key Type / Values Purpose
vulnerable boolean true if a reachable CWE vulnerability is present; false for parameterized/allowlisted/clean code
cwe_id string ("CWE-89", "NONE", ...) Normalized CWE identifier or "NONE"
severity "NONE" | "LOW" | "MEDIUM" | "HIGH" | "CRITICAL" CVSS-aligned severity band ("NONE" when safe)
title string Concise issue or verification summary
taint_flow string Source-to-sink path or sanitization justification
root_cause string Technical explanation of why the snippet is vulnerable or safe
fixed_code string Minimal corrected code when vulnerable == true, else ""

Example Input:

def get_user(conn, uid):
    return conn.execute(f"SELECT * FROM users WHERE id = {uid}").fetchall()

Observed Remote Hub bfloat16 Output (excerpt):

{
  "vulnerable": true,
  "cwe_id": "CWE-89",
  "severity": "HIGH",
  "fixed_code": "def get_user(conn, uid):\n    return conn.execute(\"SELECT * FROM users WHERE id = ?\", (uid,)).fetchall()"
}

Held-Out Unseen-Repo Evaluation (v2)

Measurement & Scoring Conditions:

  • Full-Suite Precision Parity: The full n = 500 holdout evaluation (250 vulnerable / 250 safe) now reports native bfloat16 (load_in_4bit=False) results directly matching the uploaded bfloat16 weights (greedy, do_sample=False, max_new_tokens=768, prompt truncation=True, max_length=2048) on an RTX 5080 Laptop GPU (16 GB).
  • Base A/B Comparison (n = 100): The paired baseline comparison (Qwen/Qwen3-4B-Instruct-2507 vs. ProKope-SecAudit-4B on the first 100 rows: 45 vulnerable / 55 safe) was measured under load_in_4bit=True (NF4 double-quant, bnb_4bit_compute_dtype=bfloat16).
  • Parse-Failure Accounting: In eval_secaudit.py, any response that fails parse_model_audit_json (45/500 = 9.00% in BF16; 37/500 = 7.40% in NF4) defaults to vulnerable = False — meaning parse failures on safe examples count as TN and parse failures on vulnerable examples count as FN.

1. Full Held-Out Evaluation — Native bfloat16 (n = 500: 250 Vulnerable / 250 Safe)

  • Vulnerability F1: 74.29% (Accuracy = 78.40%, Precision = 91.76%, Recall = 62.40%, FPR = 5.60%)
  • Confusion Counts: TP = 156, FP = 14, TN = 236, FN = 94 (includes 45 JSON parse failures scored as predicted False)
  • JSON Valid Rate: 91.00% (45/500 truncations / parse failures at max_new_tokens = 768; mitigated in production via vLLM guided JSON decoding)
  • CWE Exact Match: 24.00% (60/250 true vulnerable cases)
  • Candidate Patch Syntax Validity: 95.88% across 170 emitted patches (verify_patch_syntax)
  • Mean Per-Sample Latency (unbatched bfloat16): 9,889.8 ms

2. Per-Source Breakdown — Native bfloat16 (n = 500)

Source Dataset Split n (Vuln / Safe) Precision Recall Vulnerability F1 CWE Exact Counts (TP / FP / TN / FN)
ismailtasdelen/SecureCodePairs 206 (103 / 103) 100.00% 98.06% 99.02% 48 / 103 101 / 0 / 103 / 2
colin/PrimeVul 100 (50 / 50) 96.15% 50.00% 65.79% 5 / 50 25 / 1 / 49 / 25
hitoshura25/cvefixes 194 (97 / 97) 69.77% 30.93% 42.86% 7 / 97 30 / 13 / 84 / 67

3. Paired A/B Prefix Slice vs. Base Model (n = 100: 45 Vulnerable / 55 Safe, NF4 4-bit)

Model Quantization JSON Valid Accuracy Precision Recall Vulnerability F1 FPR CWE Exact Match Mean Latency
Qwen/Qwen3-4B-Instruct-2507 (Base) NF4 4-bit 97.00% 63.00% 100.00% 17.78% 30.19% 0.00% (0/55) 6.67% 5,224.7 ms
ProKope-SecAudit-4B (v2) NF4 4-bit 92.00% 82.00% 93.55% 64.44% 76.32% 3.64% (2/55) 24.44% 11,661.8 ms

Under unbatched NF4 4-bit (n = 500 reference run), ProKope-SecAudit-4B scored 74.77% F1 (89.89% Precision, 64.00% Recall, 7.20% FPR, 92.60% JSON valid, 95.51% patch syntax valid, 11,649.1 ms mean latency). Latency vs. base reflects multi-field taint_flow, root_cause, and fixed_code synthesis.


Quickstart (transformers)

import json
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

MODEL_ID = "ProKope-AI/ProKope-SecAudit-4B"

SYSTEM_PROMPT = (
    "You are ProKope-SecAudit-4B, an enterprise static and semantic security auditor. "
    "Inspect the provided code snippet or diff for real, reachable CWE vulnerabilities. "
    "Treat parameterized queries, safe parsers, strict allowlists, bounded copies, and "
    "verified auth/path containment checks as safe (vulnerable=false) to avoid false positives. "
    'Return ONLY valid JSON with exact keys: '
    '"vulnerable" (bool), "cwe_id" (string like "CWE-89" or "NONE"), '
    '"severity" ("NONE"|"LOW"|"MEDIUM"|"HIGH"|"CRITICAL"), '
    '"title" (concise string), "taint_flow" (source -> sink or sanitization note), '
    '"root_cause" (technical explanation), and "fixed_code" (minimal corrected code if vulnerable else "").'
)

def build_user_prompt(language: str, file_path: str, code_or_diff: str) -> str:
    return (
        f"Audit the following {language.strip()} source (`{file_path.strip()}`) "
        f"for reachable security vulnerabilities.\n"
        f"```{language.strip().lower()}\n{code_or_diff.strip()}\n```"
    )

tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(
    MODEL_ID,
    dtype=torch.bfloat16,
    device_map="auto",
).eval()

messages = [
    {"role": "system", "content": SYSTEM_PROMPT},
    {
        "role": "user",
        "content": build_user_prompt(
            "python",
            "app/db.py",
            'def get_user(conn, uid):\n    return conn.execute(f"SELECT * FROM users WHERE id = {uid}").fetchall()',
        ),
    },
]

inputs = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    return_tensors="pt",
    return_dict=True,
).to(model.device)

with torch.inference_mode():
    output_ids = model.generate(**inputs, max_new_tokens=768)

raw_json = tokenizer.decode(
    output_ids[0][inputs["input_ids"].shape[-1]:],
    skip_special_tokens=True,
).strip()
print(json.loads(raw_json))

Training Summary

  • Base Model: Qwen/Qwen3-4B-Instruct-2507
  • Dataset Splits: 2,088 train (2,081 kept within max_len = 1,536), 404 val (200 evaluated periodically), 500 unseen-repo test (0 rows over 1,536 tokens)
  • Optimization: Effective batch size 16 (grad_accum = 16), learning rate 1.5e-4, 2 epochs / 262 optimizer steps (~`71.02min, peak VRAM9.19 GB` on RTX 5080 Laptop GPU)
  • Validation Cross-Entropy Loss: 2.0917 (step 0) → 0.4565 (best checkpoint)

Known Limitations, Intended Use & Out-of-Scope Use

Known Limitations

  • Complex multi-file CVEs (cvefixes): Recall drops to 30.93% (42.86% F1 in BF16; 41.96% in NF4) on isolated cvefixes functions lacking cross-file call-graph and framework configuration context.
  • Language skew: 66.5% of training examples are C/C++; non-C/C++ ecosystems (especially Rust/Scala/TypeScript or framework-heavy web routes) represent smaller fractions of supervision.
  • Exact CWE ID granularity: Binary vulnerability triage is substantially stronger than exact CWE-N taxonomy matching (24.00% exact CWE overall in BF16); inspect taint_flow and root_cause during triage.
  • JSON truncation on verbose fixes: 9.00% (45/500 in BF16; 7.40% / 37/500 in NF4) of responses exceeded or broke strict JSON parsing under max_new_tokens = 768. Increase max_new_tokens or serve behind vLLM structured JSON decoding and always parse outputs defensively.

Intended Use & Security Boundary

  • Recommended Stack: Screen untrusted PR text/comments with a prompt-injection guardrail (such as ProKope-Guard-8K), scan bounded hunks/functions with ProKope-SecAudit-4B, treat returned JSON as untrusted input, and gate every candidate fixed_code patch through AST checks, compilation, and test execution before committing.

Out-of-Scope Use

  • Autonomous merging or unverified code modification in production repositories without deterministic syntax/test gates.
  • Replacement for runtime OS sandboxing, IAM/RBAC enforcement, SCA dependency scanning, or full penetration testing.
  • Dual-use exploit weaponization or automated offensive target exploitation.

Contact, Gated Access, Commercial Licensing & Trademarks

  • Organization: ProKope AI™
  • Creator: Alan Canto
  • Commercial Licensing & Enterprise Support: prokope.model@gmail.com
  • Trademark Notice (NOTICE): ProKope™, ProKope AI™, ProKope-SecAudit-4B™, ProKope-Guard-8K™, and AZAC™ are common-law trademarks of Alan Canto / ProKope AI™. Pursuant to Apache License 2.0 Section 6, model weights licensing does not grant trademark rights beyond factual origin attribution.

(Clean-room Apache-2.0 / MIT upstream provenance enables unrestricted Apache-2.0 adoption and enterprise commercial support through ProKope AI™.)

@misc{canto2026prokopesecaudit4b,
  author       = {Alan Canto},
  title        = {ProKope-SecAudit-4B: Clean-Room Commercial Code Security Auditing and Remediation Model},
  howpublished = {Hugging Face},
  year         = {2026},
  url          = {https://huggingface.co/ProKope-AI/ProKope-SecAudit-4B}
}
Downloads last month
2
Safetensors
Model size
4B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for ProKope-AI/ProKope-SecAudit-4B

Finetuned
(2,777)
this model

Datasets used to train ProKope-AI/ProKope-SecAudit-4B

Evaluation results