Downloads · 30 days
7
3% of all-time downloads
lemon42-ai/ThreatDetect-C-Cpp
ThreatDetect-C-Cpp is a text classification model from lemon42-ai. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as apache-2.0.
<img src="linkedin-deck.png" width="800"
Downloads · 30 days
7
3% of all-time downloads
All-time downloads
220
Public
Repo size
7 MB
Likes
4
Public
Click a slice to open those files.
.json3.6 MB · 43%
From the Hugging Face model README
This is a derivative version of answerdotai/ModernBERT-base. <br> We fine-tuned ModernBERT-base to detect vulnerability in C/C++ Code. <br> The actual version has an accuracy of 86% <br>
ThreatDetect-C-Cpp can be used as a code classifier. <br> Instead of binary classification ("safe", "unsafe"), The model classifies the input code into 7 labels: 'safe' (no vulnerability detected) and six other CWE weaknesses:
| Label | Description |
|---|---|
| CWE-119 | Improper Restriction of Operations within the Bounds of a Memory Buffer |
| CWE-125 | Out-of-bounds Read |
| CWE-20 | Improper Input Validation |
| CWE-416 | Use After Free |
| CWE-703 | Improper Check or Handling of Exceptional Conditions |
| CWE-787 | Out-of-bounds Write |
| safe | Safe code |
ThreadDetect-C-Cpp can be integrated in code-related applications. For example, it can be used in pair with a code generator to detect vulnerabilities in the generated code.
ThreadDetect-C-Cpp can detect weaknesses in C/C++ code only. It should not be used with other programming languages.<br> The model can only detect the six CWEs in the table above.
The model was fine-tuned on a minified, clean and deduplicated version of DiverseVul dataset. <br> This new version can be explored on HF datasets HERE
The model was trained using LoRA applied to Q and V matrices.
| Hyperparameter | Value |
|---|---|
| Max Sequence Length | 600 |
| Batch Size | 32 |
| Number of Epochs | 9 |
| Learning Rate | 5e-4 |
| Weight Decay | 0.01 |
| Logging Steps | 100 |
| LoRA Rank (r) | 8 |
| LoRA Alpha | 32 |
| LoRA Dropout | 0.1 |
| LoRA Target Modules | attn.Wqkv |
| Optimizer | AdamW |
| LR Scheduler | CosineAnnealingWarmRestarts |
| Scheduler T_0 | 10 |
| Scheduler T_mult | 2 |
| Scheduler eta_min | 1e-6 |
| Training Split Ratio | 90% Train / 10% Validation |
| Seed for Splitting | 42 |
ThreatDetect-C-Cpp reaches an accruacy of 86% on the eval set.
The model was fine-tuned on 4 Tesla V100 GPUs for 1 hour using torch + accelerate frameworks.