Text Generation
Transformers
Safetensors
English
gemma3_text
dia-guard
shield
safety
dialect
full-ft
ce
conversational
text-generation-inference
Instructions to use jsl5710/Shield-Gemma-3-270m-Full-FT-CE with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jsl5710/Shield-Gemma-3-270m-Full-FT-CE with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jsl5710/Shield-Gemma-3-270m-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-Gemma-3-270m-Full-FT-CE") model = AutoModelForCausalLM.from_pretrained("jsl5710/Shield-Gemma-3-270m-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-Gemma-3-270m-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-Gemma-3-270m-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-Gemma-3-270m-Full-FT-CE", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/jsl5710/Shield-Gemma-3-270m-Full-FT-CE
- SGLang
How to use jsl5710/Shield-Gemma-3-270m-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-Gemma-3-270m-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-Gemma-3-270m-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-Gemma-3-270m-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-Gemma-3-270m-Full-FT-CE", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use jsl5710/Shield-Gemma-3-270m-Full-FT-CE with Docker Model Runner:
docker model run hf.co/jsl5710/Shield-Gemma-3-270m-Full-FT-CE
Add holdout test set results to model card
Browse files
README.md
CHANGED
|
@@ -78,6 +78,34 @@ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
|
| 78 |
> Early stopping triggered when eval_loss did not improve for 3 consecutive evaluations.
|
| 79 |
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
## Training Setup
|
| 82 |
|
| 83 |
- **Training objective:** Cross-Entropy (next-token prediction)
|
|
|
|
| 78 |
> Early stopping triggered when eval_loss did not improve for 3 consecutive evaluations.
|
| 79 |
|
| 80 |
|
| 81 |
+
## Test Set Results
|
| 82 |
+
|
| 83 |
+
Evaluated on the **DIA-GUARD holdout test split** (181,874 samples across 48 English dialects).
|
| 84 |
+
|
| 85 |
+
| Metric | Value |
|
| 86 |
+
|--------|-------|
|
| 87 |
+
| **Test Accuracy** | **0.9654** |
|
| 88 |
+
| **Macro Precision** | 0.9676 |
|
| 89 |
+
| **Macro Recall** | 0.9634 |
|
| 90 |
+
| **Macro F1** | **0.9650** |
|
| 91 |
+
| **Support** | 181,874 |
|
| 92 |
+
|
| 93 |
+
### Per-class
|
| 94 |
+
|
| 95 |
+
| Class | Precision | Recall | F1 | Support |
|
| 96 |
+
|-------|-----------|--------|----|---------|
|
| 97 |
+
| **safe** | 0.9844 | 0.9392 | 0.9613 | 83,140 |
|
| 98 |
+
| **unsafe** | 0.9507 | 0.9875 | 0.9688 | 98,734 |
|
| 99 |
+
|
| 100 |
+
### Confusion Matrix
|
| 101 |
+
|
| 102 |
+
| | Pred safe | Pred unsafe |
|
| 103 |
+
|-------------|-----------|-------------|
|
| 104 |
+
| **True safe** | 78,087 | 5,053 |
|
| 105 |
+
| **True unsafe** | 1,234 | 97,500 |
|
| 106 |
+
|
| 107 |
+
> Per-dialect breakdown available in `per_dialect.json` in the corresponding results folder.
|
| 108 |
+
|
| 109 |
## Training Setup
|
| 110 |
|
| 111 |
- **Training objective:** Cross-Entropy (next-token prediction)
|