Feature Extraction
sentence-transformers
PyTorch
English
Vietnamese
xlm-roberta
embedding
dense-retrieval
contrastive-learning
cve
cybersecurity
qdrant
secAI
text-embeddings-inference
Instructions to use DuyTa/sec-embedding with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use DuyTa/sec-embedding with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("DuyTa/sec-embedding") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Model card: fine-tuned BGE-M3 dense retriever (Qdrant CVE hard-negative trajectories)
Browse files
README.md
CHANGED
|
@@ -7,6 +7,7 @@ pipeline_tag: feature-extraction
|
|
| 7 |
language:
|
| 8 |
- en
|
| 9 |
- vi
|
|
|
|
| 10 |
tags:
|
| 11 |
- sentence-transformers
|
| 12 |
- feature-extraction
|
|
@@ -21,36 +22,34 @@ tags:
|
|
| 21 |
|
| 22 |
# sec-embedding
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
## Training
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
| | |
|
| 33 |
|---|---|
|
| 34 |
| Base | `BAAI/bge-m3` via Unsloth `FastSentenceTransformer` (`unsloth/bge-m3`) |
|
| 35 |
-
|
|
| 36 |
-
| Adapter | LoRA, `r=32`,
|
| 37 |
-
| Loss | `CachedMultipleNegativesRankingLoss` (InfoNCE
|
| 38 |
| Engine | `sentence-transformers` `SentenceTransformerTrainer` |
|
| 39 |
| Max sequence length | 1024 |
|
| 40 |
| Learning rate | 2e-5, bf16 |
|
| 41 |
|
| 42 |
-
Each
|
| 43 |
|
| 44 |
-
- **Query** —
|
| 45 |
-
- **Positive** —
|
| 46 |
-
- **Hard negatives** — other CVE documents in the same mini-batch, all mined from that Qdrant index
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
## Usage
|
| 51 |
|
| 52 |
-
Drop-in replacement for bge-m3 in sentence-transformers. Rebuild the Qdrant index with **this** checkpoint; mixing it with vanilla bge-m3 vectors collapses recall.
|
| 53 |
-
|
| 54 |
```python
|
| 55 |
from sentence_transformers import SentenceTransformer
|
| 56 |
|
|
@@ -59,6 +58,8 @@ query_emb = model.encode("CVE-2021-44228 impact on log4j", normalize_embeddings=
|
|
| 59 |
doc_emb = model.encode(passage, normalize_embeddings=True)
|
| 60 |
```
|
| 61 |
|
|
|
|
|
|
|
| 62 |
## Attribution & license
|
| 63 |
|
| 64 |
-
|
|
|
|
| 7 |
language:
|
| 8 |
- en
|
| 9 |
- vi
|
| 10 |
+
pretty_name: sec-embedding (fine-tuned BGE-M3)
|
| 11 |
tags:
|
| 12 |
- sentence-transformers
|
| 13 |
- feature-extraction
|
|
|
|
| 22 |
|
| 23 |
# sec-embedding
|
| 24 |
|
| 25 |
+
**This is a fine-tuned version of [BAAI/bge-m3](https://huggingface.co/BAAI/bge-m3)** for CVE / cybersecurity dense retrieval.
|
| 26 |
|
| 27 |
+
It was trained on a **CVE investigation-trajectory dataset** with **hard-negative mining** from a **local Qdrant** collection (`cve_kb`, NVD/MITRE core chunks). It is not a raw copy of the base checkpoint.
|
| 28 |
|
| 29 |
## Training
|
| 30 |
|
| 31 |
+
From `notebooks/BGE_M3_Colab.ipynb`:
|
| 32 |
|
| 33 |
| | |
|
| 34 |
|---|---|
|
| 35 |
| Base | `BAAI/bge-m3` via Unsloth `FastSentenceTransformer` (`unsloth/bge-m3`) |
|
| 36 |
+
| Role | Bi-encoder / **dense retriever** (1024-d, same geometry as bge-m3) |
|
| 37 |
+
| Adapter | LoRA, `r=32`, modules `key`, `query`, `value`, `dense` |
|
| 38 |
+
| Loss | `CachedMultipleNegativesRankingLoss` (InfoNCE, in-batch hard negatives) |
|
| 39 |
| Engine | `sentence-transformers` `SentenceTransformerTrainer` |
|
| 40 |
| Max sequence length | 1024 |
|
| 41 |
| Learning rate | 2e-5, bf16 |
|
| 42 |
|
| 43 |
+
Each example is a `(query, positive)` pair:
|
| 44 |
|
| 45 |
+
- **Query** — CVE investigation trajectory (Vietnamese or English) over CVE-ID, CWE, product, severity, year, CAPEC / ATT&CK, filled from real KB metadata.
|
| 46 |
+
- **Positive** — matching CVE passage from local Qdrant `cve_kb`.
|
| 47 |
+
- **Hard negatives** — other CVE documents in the same mini-batch, all mined from that Qdrant index (near-miss CVEs: similar wording, wrong ID).
|
| 48 |
|
| 49 |
+
Dataset source field: `Qdrant cve_kb (NVD/MITRE)`. Split: 40k train / 5k validation.
|
| 50 |
|
| 51 |
## Usage
|
| 52 |
|
|
|
|
|
|
|
| 53 |
```python
|
| 54 |
from sentence_transformers import SentenceTransformer
|
| 55 |
|
|
|
|
| 58 |
doc_emb = model.encode(passage, normalize_embeddings=True)
|
| 59 |
```
|
| 60 |
|
| 61 |
+
Rebuild the Qdrant index with **this** checkpoint. Mixing vectors with vanilla `BAAI/bge-m3` drops recall.
|
| 62 |
+
|
| 63 |
## Attribution & license
|
| 64 |
|
| 65 |
+
Derived from [BAAI/bge-m3](https://huggingface.co/BAAI/bge-m3) (**MIT License**). Credit for the base model belongs to the BAAI authors.
|