Datasets:
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -16,13 +16,11 @@ size_categories:
|
|
| 16 |
|
| 17 |
# PrimeVul CodeBERT Embeddings
|
| 18 |
|
| 19 |
-
Pre-extracted [CLS] token embeddings from microsoft/codebert-base for all functions in the PrimeVul v0.1 vulnerability detection dataset.
|
| 20 |
|
| 21 |
-
##
|
| 22 |
|
| 23 |
-
Each .npz file contains frozen CodeBERT embeddings (768-dimensional vectors) for C/C++ functions, along with their labels and CWE type annotations. These
|
| 24 |
-
|
| 25 |
-
## Files
|
| 26 |
|
| 27 |
| File | Functions | Vulnerable | Shape |
|
| 28 |
|------|-----------|-----------|-------|
|
|
@@ -31,24 +29,39 @@ Each .npz file contains frozen CodeBERT embeddings (768-dimensional vectors) for
|
|
| 31 |
| test.npz | 24,788 | 549 (2.21%) | (24788, 768) |
|
| 32 |
| test_paired.npz | 870 | 435 (50%) | (870, 768) |
|
| 33 |
|
| 34 |
-
|
| 35 |
|
| 36 |
- embeddings: (N, 768) float32 -- CodeBERT [CLS] token vectors
|
| 37 |
- labels: (N,) int32 -- 0 = benign, 1 = vulnerable
|
| 38 |
-
- cwe_types: (N,)
|
| 39 |
- idxs: (N,) int64 -- original PrimeVul record index for traceability
|
| 40 |
|
| 41 |
-
## How to
|
| 42 |
|
| 43 |
```python
|
| 44 |
import numpy as np
|
| 45 |
|
| 46 |
-
data = np.load("train.npz"
|
| 47 |
X = data["embeddings"] # (175797, 768)
|
| 48 |
y = data["labels"] # (175797,)
|
| 49 |
cwes = data["cwe_types"] # (175797,)
|
| 50 |
```
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
## Extraction details
|
| 53 |
|
| 54 |
- Model: microsoft/codebert-base (RoBERTa architecture, 125M parameters)
|
|
@@ -59,7 +72,7 @@ cwes = data["cwe_types"] # (175797,)
|
|
| 59 |
|
| 60 |
## Citation
|
| 61 |
|
| 62 |
-
If you use
|
| 63 |
|
| 64 |
```bibtex
|
| 65 |
@article{ding2024primevul,
|
|
|
|
| 16 |
|
| 17 |
# PrimeVul CodeBERT Embeddings
|
| 18 |
|
| 19 |
+
Pre-extracted [CLS] token embeddings from microsoft/codebert-base for all functions in the PrimeVul v0.1 vulnerability detection dataset, plus the raw PrimeVul v0.1 JSONL source files.
|
| 20 |
|
| 21 |
+
## Embeddings (.npz files)
|
| 22 |
|
| 23 |
+
Each .npz file contains frozen CodeBERT embeddings (768-dimensional vectors) for C/C++ functions, along with their labels and CWE type annotations. These were extracted once using a frozen CodeBERT model and are used for downstream PU (positive-unlabeled) learning experiments without requiring GPU access.
|
|
|
|
|
|
|
| 24 |
|
| 25 |
| File | Functions | Vulnerable | Shape |
|
| 26 |
|------|-----------|-----------|-------|
|
|
|
|
| 29 |
| test.npz | 24,788 | 549 (2.21%) | (24788, 768) |
|
| 30 |
| test_paired.npz | 870 | 435 (50%) | (870, 768) |
|
| 31 |
|
| 32 |
+
Arrays in each .npz:
|
| 33 |
|
| 34 |
- embeddings: (N, 768) float32 -- CodeBERT [CLS] token vectors
|
| 35 |
- labels: (N,) int32 -- 0 = benign, 1 = vulnerable
|
| 36 |
+
- cwe_types: (N,) U20 string -- CWE category (e.g., "CWE-119") or "unknown"
|
| 37 |
- idxs: (N,) int64 -- original PrimeVul record index for traceability
|
| 38 |
|
| 39 |
+
### How to load
|
| 40 |
|
| 41 |
```python
|
| 42 |
import numpy as np
|
| 43 |
|
| 44 |
+
data = np.load("train.npz")
|
| 45 |
X = data["embeddings"] # (175797, 768)
|
| 46 |
y = data["labels"] # (175797,)
|
| 47 |
cwes = data["cwe_types"] # (175797,)
|
| 48 |
```
|
| 49 |
|
| 50 |
+
No special flags needed. All arrays use standard numpy dtypes (float32, int32, U20, int64).
|
| 51 |
+
|
| 52 |
+
## Raw PrimeVul v0.1 data (raw/ folder)
|
| 53 |
+
|
| 54 |
+
The raw/ folder contains the original PrimeVul v0.1 JSONL files from the PrimeVul project. Each line is a JSON object with fields including func (source code), target (0/1 label), cwe (list of CWE strings), cve (CVE identifier), and project metadata.
|
| 55 |
+
|
| 56 |
+
| File | Records |
|
| 57 |
+
|------|---------|
|
| 58 |
+
| raw/primevul_train.jsonl | 175,797 |
|
| 59 |
+
| raw/primevul_valid.jsonl | 23,948 |
|
| 60 |
+
| raw/primevul_test.jsonl | 24,788 |
|
| 61 |
+
| raw/primevul_train_paired.jsonl | 9,724 |
|
| 62 |
+
| raw/primevul_valid_paired.jsonl | 870 |
|
| 63 |
+
| raw/primevul_test_paired.jsonl | 870 |
|
| 64 |
+
|
| 65 |
## Extraction details
|
| 66 |
|
| 67 |
- Model: microsoft/codebert-base (RoBERTa architecture, 125M parameters)
|
|
|
|
| 72 |
|
| 73 |
## Citation
|
| 74 |
|
| 75 |
+
If you use this data, please cite the PrimeVul dataset:
|
| 76 |
|
| 77 |
```bibtex
|
| 78 |
@article{ding2024primevul,
|