CoolFace
Modelpublic

RamzyBakir/Secure-SmolLM3-3B

sourceHugging Faceapache-2.0updated 10mo agoView on Hugging Face
3likes48downloads
Model Card

CySent-SmolLM3-3B

<p align="center"> <img src="https://www.cysent.org/_next/image?url=%2Fimages%2FCySent.png&w=384&q=100" width="400"/> <p>

CySent-SmolLM3-3B is a fine-tuned version of 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. This model aims to act as a knowledgeable assistant for a wide range of cybersecurity topics. It achieves the following results on the evaluation set:

  • Loss: 0.757
  • Mean Token Accuracy: 0.796

Intended uses

This model is designed to assist with a variety of natural language cybersecurity tasks, including:

  • Answering technical questions about security concepts.
  • Explaining vulnerabilities, attack vectors, and defense mechanisms.
  • Generating simple security-related scripts or commands (e.g., for network analysis or pentesting).
  • Summarizing security logs, reports, or articles.
  • Assisting in educational settings for cybersecurity students and professionals.

It is intended as a co-pilot or assistant and not as a standalone, automated security tool.

Limitations

  • Not for Real-Time Threat Detection: This model is not designed for or capable of real-time intrusion detection or automated threat response.
  • Potential for Hallucination: Like all language models, it may generate incorrect, outdated, or completely fabricated information. Always verify critical information from authoritative sources.
  • Inherited Biases: The model may inherit biases and limitations from its base model (SmolLM3-3B) and the fine-tuning dataset.
  • 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.
  • Misuse Potential: The model could potentially be used to generate malicious code or instructions for harmful purposes. Please use it responsibly and ethically.

How to use

python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "RamzyBakir/CySent-SmolLM3-3B"

# Load the model and tokenizer
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.bfloat16,
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)

# Create a prompt
prompt = "### Instruction:\nExplain what a SQL injection attack is and provide a simple example of a vulnerable code snippet.\n\n### Response:\n"

# Generate a response
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
output = model.generate(**inputs, max_new_tokens=250, do_sample=True, temperature=0.7, top_p=0.9)

# Decode and print the result
response = tokenizer.decode(output[0], skip_special_tokens=True)
print(response)

Training procedure

Training hyperparameters

The model was fine-tuned using Low-Rank Adaptation (LoRA) with the following configuration:

SFTConfig:

  • max_length: 2048
  • per_device_train_batch_size: 8
  • gradient_accumulation_steps: 2
  • learning_rate: 1e-4
  • num_train_epochs: 3
  • warmup_ratio: 0.1
  • weight_decay: 0.01
  • optim: adamw_torch
  • bf16: True
  • eval_strategy: steps
  • eval_steps: 200
  • save_steps: 200
  • metric_for_best_model: eval_loss

LoraConfig:

  • r: 16
  • lora_alpha: 32
  • lora_dropout: 0.05
  • task_type: CAUSAL_LM
  • target_modules: ["qproj", "kproj", "vproj", "oproj"]

Training results

The model was trained for 3200 steps on a single H200 GPU. The training and validation metrics progressed as follows:

StepTraining LossValidation LossEntropyNum TokensMean Token Accuracy
2001.1115001.0454371.0022002,182,437.000.740981
4000.9759000.9446840.9178574,368,626.000.759094
8000.8635000.8607050.8625498,721,104.000.775031
12000.8349000.8163420.84936513,096,717.000.784405
16000.7922000.7940830.80218217,452,772.000.788403
20000.7779000.7795760.79062721,807,624.000.791107
24000.7498000.7717200.76168926,151,814.000.792799
28000.7478000.7629570.76158830,504,962.000.794528
32000.7358000.7573950.75757534,860,059.000.795802

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.