Instructions to use jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE") model = AutoModelForCausalLM.from_pretrained("jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE
- SGLang
How to use jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE with Docker Model Runner:
docker model run hf.co/jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE
SmolLM2-1.7B โ Full-FT/CE (Shield Project)
This model is part of the Shield project โ a collection of safety-classifier models fine-tuned on the DIA-GUARD dataset (48 English dialects, ~836K records of safe/unsafe prompts) to robustly classify harmful content across diverse dialects.
Model Summary
| Field | Value |
|---|---|
| Base model | HuggingFaceTB/SmolLM2-1.7B-Instruct |
| Training method | Full-FT (CE loss) |
| Training data | DIA-GUARD splits (~836K train, 178K val) |
| Domain | LLM safety classification across 48 English dialects |
| Role | Student model (used as KD student in DIA-GUARD pipeline) |
| License | Apache 2.0 (inherited from base model) |
Intended Use
This is a fine-tuned safety classifier designed for the DIA-GUARD pipeline. It is intended for use as:
- A safety filter โ classify input prompts as
safeorunsafeacross English dialects - A teacher/student in knowledge distillation โ these checkpoints are used as the student models for downstream KD experiments (MINILLM / GKD / TED)
- A research baseline โ for studies on dialect-aware safety in LLMs
How to use
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE", torch_dtype="bfloat16")
tokenizer = AutoTokenizer.from_pretrained("jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE")
prompt = "<your prompt here>"
inputs = tokenizer.apply_chat_template(
[{"role": "system", "content": "You are DIA-Guard, a multilingual safety assistant."},
{"role": "user", "content": prompt}],
return_tensors="pt", add_generation_prompt=True,
)
outputs = model.generate(inputs, max_new_tokens=4)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
# Expected: 'safe' or 'unsafe'
Performance
| Metric | Value |
|---|---|
| Final epoch | 0.60/3 (early-stopped) |
| Train loss | 0.6234 |
| Train accuracy | 82.67% |
| Eval loss | 0.7843 |
| Eval accuracy | 77.93% |
| Batch size (per_device ร grad_accum) | 64 ร 1 = 64 |
| Liger Kernel | โ enabled |
| Stopped via | EarlyStoppingCallback (patience=3, metric=eval_loss) |
Eval was performed on a 2,000-sample subset of the DIA-GUARD val split (full val: 178K samples). Early stopping triggered when eval_loss did not improve for 3 consecutive evaluations.
Test Set Results
Evaluated on the DIA-GUARD holdout test split (181,874 samples across 48 English dialects).
| Metric | Value |
|---|---|
| Test Accuracy | 0.7481 |
| Macro Precision | 0.7732 |
| Macro Recall | 0.7601 |
| Macro F1 | 0.7467 |
| Support | 181,874 |
Per-class
| Class | Precision | Recall | F1 | Support |
|---|---|---|---|---|
| safe | 0.6663 | 0.8996 | 0.7655 | 83,140 |
| unsafe | 0.8801 | 0.6206 | 0.7279 | 98,734 |
Confusion Matrix
| Pred safe | Pred unsafe | |
|---|---|---|
| True safe | 74,791 | 8,349 |
| True unsafe | 37,461 | 61,273 |
Per-dialect breakdown available in
per_dialect.jsonin the corresponding results folder.
Training Setup
- Training objective: Cross-Entropy (next-token prediction)
- Optimizer: AdamW with cosine LR schedule
- Precision: bf16 mixed precision
- Frameworks: transformers, peft, trl, accelerate
- Hardware: A100 40GB
- Optimization: Liger Kernel (fused lm_head + cross-entropy)
Dataset
DIA-GUARD โ 48 English dialects ร multi-source safety benchmarks, with both harmful prompts and benign counter-examples generated via the CounterHarm-SHIELD pipeline.
- ~836K train / ~178K eval samples
- 50% safe / 50% unsafe split (approximate)
- Available at:
jsl5710/Shield
Citation
@misc{diaguard2026,
title = {DIA-GUARD: Dialect-Informed Adversarial Guard for LLM Safety},
author = {Jason Lucas et al.},
year = {2026},
howpublished = {\url{https://github.com/jsl5710/dia-guard}}
}
Limitations
- The model inherits the limitations and biases of the base model
- Trained primarily on English dialects โ performance on non-English text is not guaranteed
- Should not be used as the sole safety mechanism in production systems
License
This model is released under the Apache 2.0, inherited from the base model. Please review the base model's license at the link above before use.
- Downloads last month
- 12
Model tree for jsl5710/Shield-SmolLM2-1.7B-Full-FT-CE
Base model
HuggingFaceTB/SmolLM2-1.7B