Text Classification
Transformers
Safetensors
roberta
codebert
cybersecurity
vulnerability-detection
code
security
text-embeddings-inference
Run this model with HF Jobs
Run MhamedRayan/devsecops-transformer on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/MhamedRayan/devsecops-transformer. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/MhamedRayan/devsecops-transformer on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use MhamedRayan/devsecops-transformer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MhamedRayan/devsecops-transformer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="MhamedRayan/devsecops-transformer")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("MhamedRayan/devsecops-transformer") model = AutoModelForSequenceClassification.from_pretrained("MhamedRayan/devsecops-transformer", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071---license: otherlibrary_name: transformerspipeline_tag: text-classificationbase_model: microsoft/codebert-basetags: - codebert - cybersecurity - vulnerability-detection - code - security - text-classification---
# Agent 2 — CodeBERT Vulnerability Classifier
CodeBERT-base fine-tuned to flag vulnerabilities in C/C++ source code.Part of a three-agent DevSecOps auditor (metrics → transformer → gatekeeper).
## Files
| File | Purpose ||---|---|| `config.json` | Architecture; `label2id` = `{"SAFE": 0, "VULNERABLE": 1}` || `model.safetensors` | Fine-tuned weights (~476 MB) || `tokenizer.json` | Fast tokenizer || `tokenizer_config.json` | Tokenizer settings || `meta.json` | Extra wrapper metadata (threshold, max length, metrics) |
`meta.json` is not used by `transformers`; the values are repeated here.
## Specs
- Base model: `microsoft/codebert-base`- Labels: `SAFE` (0), `VULNERABLE` (1)- Max length: **384** tokens (longer input is truncated)- Decision threshold: **0.45**- Training data: CodeXGLUE defect detection + DiverseVul (C/C++)
| Metric | Value ||---|---|| F1 | 0.6881 || Precision | 0.5804 || Recall | 0.8450 || ROC-AUC | 0.7475 |
Recall is prioritized over precision, so false positives are expected. Scoresare softmax outputs, not calibrated probabilities. Non-C/C++ code isout-of-distribution.
## Usage
```pythonimport torchfrom transformers import AutoModelForSequenceClassification, AutoTokenizer
name = "your-username/agent2-codebert-vuln"tok = AutoTokenizer.from_pretrained(name)model = AutoModelForSequenceClassification.from_pretrained(name).eval()
inputs = tok(code, return_tensors="pt", truncation=True, max_length=384)with torch.inference_mode(): logits = model(**inputs).logits
p_vuln = torch.softmax(logits, -1)[0, model.config.label2id["VULNERABLE"]].item()vulnerable = p_vuln >= 0.45```
## License
Not specified. Update the `license` field before publishing.README.mdAdded+71