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 Apache-2.0/MIT upstream dataset lineage 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 (Permissive OSS Datasets) hitoshura25/cvefixes (Apache-2.0), ismailtasdelen/SecureCodePairs (MIT), colin/PrimeVul (MIT) — verbatim third-party open-source repository code across 488 repo groups (including Linux kernel, TensorFlow, FFmpeg, OpenSSL); not synthetic/clean-room authored
Leakage & Decontamination Controls 50/50 vulnerable/safe pairing per source (train = 2,088, val = 404, test = 500); 0 exact, normalized, 8-gram/13-gram, and repository-group overlap across train/val/test
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) — Full n = 500 Precision Parity

Measurement & Precision Parity Conditions:

  • One Model Across Both Precisions (~`78.4%Acc /74.3–74.8%` F1): Full n = 500 unseen-repo holdout evaluation (250 vulnerable / 250 safe, greedy do_sample=False, max_new_tokens=768, prompt truncation=True, max_length=2048) was executed on an RTX 5080 Laptop GPU (16 GB) in both native bfloat16 and NF4 4-bit. Small precision/recall variations (91.76% vs. 89.89% precision; 74.29% vs. 74.77% F1; identical 78.40% accuracy) are within sample noise and should not be treated as a real BF16 precision advantage over NF4.
  • 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 (n = 500: 250 Vulnerable / 250 Safe, RTX 5080)

Precision Accuracy Precision Recall Vulnerability F1 FPR JSON Valid Patch Syntax Valid Mean Latency
Native bfloat16 78.40% 91.76% 62.40% 74.29% 5.60% 91.00% 95.88% (170 patches) 9,889.8 ms
NF4 4-bit 78.40% 89.89% 64.00% 74.77% 7.20% 92.60% 95.51% 11,649.1 ms
  • Native bfloat16 Confusion Counts: TP = 156, FP = 14, TN = 236, FN = 94 (includes 45 JSON parse failures scored as predicted False); CWE exact match 24.00% (60/250).

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) Notes
ismailtasdelen/SecureCodePairs 206 (103 / 103) 100.00% 98.06% 99.02% 48 / 103 101 / 0 / 103 / 2 Strongest domain
colin/PrimeVul 100 (50 / 50) 96.15% 50.00% 65.79% 5 / 50 25 / 1 / 49 / 25 High precision, moderate recall
hitoshura25/cvefixes 194 (97 / 97) 69.77% 30.93% 42.86% 7 / 97 30 / 13 / 84 / 67 Weakest domain — isolated multi-file CVE snippets underperform classical lexical baselines

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

Note: This n = 100 prefix slice is slightly easier than the full n = 500 split (82.00% vs. 78.40% Acc) and is included strictly for the paired NF4 base-vs-finetuned comparison.

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

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 (Transparent Disclosure)

  • Real-world multi-file patches (cvefixes): ProKope-SecAudit-4B earns its keep on SecureCodePairs (99.02% F1) and PrimeVul (65.79% F1), not yet on isolated cvefixes patches (42.86% F1 / 30.93% recall in BF16; 41.96% F1 in NF4), where simple lexical/linear classifiers remain competitive on snippet-level cues lacking cross-file call-graph context. Improving multi-file real-world CVE recall is the primary v3 roadmap target.
  • 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, Licensing & Trademarks

  • Organization: ProKope AI™
  • Creator: Alan Canto
  • Commercial Support Inquiries: prokope.model@gmail.com
  • Trademark & Attribution 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.
@misc{canto2026prokopesecaudit4b,
  author       = {Alan Canto},
  title        = {ProKope-SecAudit-4B: Open-Weight Code Security Auditing and Remediation Model},
  howpublished = {Hugging Face},
  year         = {2026},
  url          = {https://huggingface.co/ProKope-AI/ProKope-SecAudit-4B}
}
Downloads last month
4
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,836)
this model

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

Evaluation results