Update README.md
Browse files
README.md
CHANGED
|
@@ -1,199 +1,126 @@
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
|
|
|
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
|
| 14 |
-
###
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
-
|
| 51 |
|
| 52 |
-
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
## Bias, Risks, and Limitations
|
| 59 |
-
|
| 60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 61 |
-
|
| 62 |
-
[More Information Needed]
|
| 63 |
-
|
| 64 |
-
### Recommendations
|
| 65 |
-
|
| 66 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
-
|
| 70 |
-
## How to Get Started with the Model
|
| 71 |
-
|
| 72 |
-
Use the code below to get started with the model.
|
| 73 |
-
|
| 74 |
-
[More Information Needed]
|
| 75 |
-
|
| 76 |
-
## Training Details
|
| 77 |
-
|
| 78 |
-
### Training Data
|
| 79 |
-
|
| 80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
### Training Procedure
|
| 85 |
-
|
| 86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
|
| 199 |
-
[More Information Needed]
|
|
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
base_model: HuggingFaceTB/SmolLM3-3B
|
| 5 |
+
metrics:
|
| 6 |
+
- accuracy
|
| 7 |
+
- Training Loss
|
| 8 |
+
- Validation Loss
|
| 9 |
+
datasets:
|
| 10 |
+
- Trendyol/Trendyol-Cybersecurity-Instruction-Tuning-Dataset
|
| 11 |
+
pipeline_tag: text-generation
|
| 12 |
+
tags:
|
| 13 |
+
- cybersecurity
|
| 14 |
+
- instruction-tuning
|
| 15 |
+
- security
|
| 16 |
+
- smolm
|
| 17 |
+
- lora
|
| 18 |
---
|
| 19 |
+
# CySent-SmolLM3-3B
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
<p align="center">
|
| 23 |
+
<img src="https://www.cysent.org/_next/image?url=%2Fimages%2FCySent.png&w=384&q=100" width="400"/>
|
| 24 |
+
<p>
|
| 25 |
|
| 26 |
+
CySent-SmolLM3-3B is a fine-tuned version of [HuggingFaceTB/SmolLM3-3B](https://huggingface.co/HuggingFaceTB/SmolLM3-3B), specifically adapted for cybersecurity instruction-following tasks. It was trained on a 20,000-sample subset of the [Trendyol/Trendyol-Cybersecurity-Instruction-Tuning-Dataset](https://huggingface.co/datasets/Trendyol/Trendyol-Cybersecurity-Instruction-Tuning-Dataset). This model aims to act as a knowledgeable assistant for a wide range of cybersecurity topics.
|
| 27 |
+
It achieves the following results on the evaluation set:
|
| 28 |
+
- **Loss:** 0.757
|
| 29 |
+
- **Mean Token Accuracy:** 0.796
|
| 30 |
|
| 31 |
+
### Intended uses
|
| 32 |
|
| 33 |
+
This model is designed to assist with a variety of natural language cybersecurity tasks, including:
|
| 34 |
|
| 35 |
+
- Answering technical questions about security concepts.
|
| 36 |
+
- Explaining vulnerabilities, attack vectors, and defense mechanisms.
|
| 37 |
+
- Generating simple security-related scripts or commands (e.g., for network analysis or pentesting).
|
| 38 |
+
- Summarizing security logs, reports, or articles.
|
| 39 |
+
- Assisting in educational settings for cybersecurity students and professionals.
|
| 40 |
|
| 41 |
+
It is intended as a **co-pilot or assistant** and not as a standalone, automated security tool.
|
| 42 |
|
| 43 |
+
### Limitations
|
| 44 |
|
| 45 |
+
- **Not for Real-Time Threat Detection:** This model is not designed for or capable of real-time intrusion detection or automated threat response.
|
| 46 |
+
- **Potential for Hallucination:** Like all language models, it may generate incorrect, outdated, or completely fabricated information. Always verify critical information from authoritative sources.
|
| 47 |
+
- **Inherited Biases:** The model may inherit biases and limitations from its base model (SmolLM3-3B) and the fine-tuning dataset.
|
| 48 |
+
- **Knowledge Cutoff:** The model's knowledge is limited to the data it was trained on and may not be aware of the very latest vulnerabilities or security trends.
|
| 49 |
+
- **Misuse Potential:** The model could potentially be used to generate malicious code or instructions for harmful purposes. Please use it responsibly and ethically.
|
| 50 |
|
| 51 |
+
## How to use
|
| 52 |
|
| 53 |
+
```python
|
| 54 |
+
import torch
|
| 55 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
+
model_name = "RamzyBakir/CySent-SmolLM3-3B"
|
| 58 |
|
| 59 |
+
# Load the model and tokenizer
|
| 60 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 61 |
+
model_name,
|
| 62 |
+
torch_dtype=torch.bfloat16,
|
| 63 |
+
device_map="auto"
|
| 64 |
+
)
|
| 65 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 66 |
|
| 67 |
+
# Create a prompt
|
| 68 |
+
prompt = "### Instruction:\nExplain what a SQL injection attack is and provide a simple example of a vulnerable code snippet.\n\n### Response:\n"
|
|
|
|
| 69 |
|
| 70 |
+
# Generate a response
|
| 71 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 72 |
+
output = model.generate(**inputs, max_new_tokens=250, do_sample=True, temperature=0.7, top_p=0.9)
|
| 73 |
|
| 74 |
+
# Decode and print the result
|
| 75 |
+
response = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 76 |
+
print(response)
|
| 77 |
+
```
|
| 78 |
|
| 79 |
+
## Training procedure
|
| 80 |
|
| 81 |
+
### Training hyperparameters
|
| 82 |
|
| 83 |
+
The model was fine-tuned using Low-Rank Adaptation (LoRA) with the following configuration:
|
| 84 |
|
| 85 |
+
**SFTConfig:**
|
| 86 |
+
- `max_length`: 2048
|
| 87 |
+
- `per_device_train_batch_size`: 8
|
| 88 |
+
- `gradient_accumulation_steps`: 2
|
| 89 |
+
- `learning_rate`: 1e-4
|
| 90 |
+
- `num_train_epochs`: 3
|
| 91 |
+
- `warmup_ratio`: 0.1
|
| 92 |
+
- `weight_decay`: 0.01
|
| 93 |
+
- `optim`: adamw_torch
|
| 94 |
+
- `bf16`: True
|
| 95 |
+
- `eval_strategy`: steps
|
| 96 |
+
- `eval_steps`: 200
|
| 97 |
+
- `save_steps`: 200
|
| 98 |
+
- `metric_for_best_model`: eval_loss
|
| 99 |
|
| 100 |
+
**LoraConfig:**
|
| 101 |
+
- `r`: 16
|
| 102 |
+
- `lora_alpha`: 32
|
| 103 |
+
- `lora_dropout`: 0.05
|
| 104 |
+
- `task_type`: CAUSAL_LM
|
| 105 |
+
- `target_modules`: ["q_proj", "k_proj", "v_proj", "o_proj"]
|
| 106 |
|
| 107 |
+
### Training results
|
| 108 |
|
| 109 |
+
The model was trained for 3200 steps on a single H200 GPU. The training and validation metrics progressed as follows:
|
| 110 |
|
| 111 |
+
| Step | Training Loss | Validation Loss | Entropy | Num Tokens | Mean Token Accuracy |
|
| 112 |
+
|------|---------------|-----------------|----------|-----------------|---------------------|
|
| 113 |
+
| 200 | 1.111500 | 1.045437 | 1.002200 | 2,182,437.00 | 0.740981 |
|
| 114 |
+
| 400 | 0.975900 | 0.944684 | 0.917857 | 4,368,626.00 | 0.759094 |
|
| 115 |
+
| 800 | 0.863500 | 0.860705 | 0.862549 | 8,721,104.00 | 0.775031 |
|
| 116 |
+
| 1200 | 0.834900 | 0.816342 | 0.849365 | 13,096,717.00 | 0.784405 |
|
| 117 |
+
| 1600 | 0.792200 | 0.794083 | 0.802182 | 17,452,772.00 | 0.788403 |
|
| 118 |
+
| 2000 | 0.777900 | 0.779576 | 0.790627 | 21,807,624.00 | 0.791107 |
|
| 119 |
+
| 2400 | 0.749800 | 0.771720 | 0.761689 | 26,151,814.00 | 0.792799 |
|
| 120 |
+
| 2800 | 0.747800 | 0.762957 | 0.761588 | 30,504,962.00 | 0.794528 |
|
| 121 |
+
| 3200 | 0.735800 | 0.757395 | 0.757575 | 34,860,059.00 | 0.795802 |
|
| 122 |
+
|
| 123 |
+
The model achieved its best performance at the final step, with a validation loss of **0.757** and a mean token accuracy of **0.796**.
|
| 124 |
|
| 125 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
|
|