Instructions to use Andrefty/qwen3-4b-vuln-sft-research with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Andrefty/qwen3-4b-vuln-sft-research with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Andrefty/qwen3-4b-vuln-sft-research") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Andrefty/qwen3-4b-vuln-sft-research") model = AutoModelForCausalLM.from_pretrained("Andrefty/qwen3-4b-vuln-sft-research", 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 Andrefty/qwen3-4b-vuln-sft-research with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Andrefty/qwen3-4b-vuln-sft-research" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Andrefty/qwen3-4b-vuln-sft-research", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Andrefty/qwen3-4b-vuln-sft-research
- SGLang
How to use Andrefty/qwen3-4b-vuln-sft-research 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 "Andrefty/qwen3-4b-vuln-sft-research" \ --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": "Andrefty/qwen3-4b-vuln-sft-research", "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 "Andrefty/qwen3-4b-vuln-sft-research" \ --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": "Andrefty/qwen3-4b-vuln-sft-research", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Andrefty/qwen3-4b-vuln-sft-research with Docker Model Runner:
docker model run hf.co/Andrefty/qwen3-4b-vuln-sft-research
Qwen3-4B Vulnerability Detection - SFT (Research)
This model is a full fine-tuned version of Qwen/Qwen3-4B for code vulnerability detection.
Model Description
- Base Model: Qwen/Qwen3-4B
- Training Method: Supervised Fine-Tuning (SFT)
- Task: Binary classification of code vulnerabilities + vulnerable line localization
- Training Data: Teacher-annotated vulnerability samples from PrimeVul, SVEN, and SecVulEval datasets (~15,100 samples generated from the ~12,900 deduplicated functions in the updated merged dataset)
Training Configuration
- Learning rate: 2e-5 with 3% warmup
- Batch size: 1 per device × 16 gradient accumulation steps
- Max sequence length: 32,768 tokens
- Epochs: 1
- Gradient checkpointing: Enabled
- Distributed: DeepSpeed ZeRO-3 across 3× H100 GPUs
- Precision: BF16
Evaluation Results (Combined - Training Set)
Note: These results are from the sft_qwen3_4b_newrewards_backtoSFThints_butnoGRPOhints_afterdedupandidfix_multitemp_run1 (temperature 0.4) evaluation run (best P-C of this specific model). This model keeps the exact same configuration as the previous run (d450f3e02358050fb65ae426f5185a2e2b09d203), with the exception of re-introducing hints for SFT training:
- Re-introduced hints for SFT training (GRPO remains hint-free).
- Evaluation with concurrency of 32 for some runs.
| Metric | Value |
|---|---|
| Accuracy | 0.5599 |
| F1 Score | 0.6105 |
| P-C (Pair-Correct) | 26.196% |
| P-V (Pair-Vulnerable) | 42.420% |
| P-B (Pair-Benign) | 17.553% |
| P-R (Pair-Reversed) | 13.829% |
Full metrics JSON files are available in sft_qwen3_4b_eval_results. See the specific metrics from above here: sft_qwen3_4b_eval_results/sft_qwen3_4b_newrewards_backtoSFThints_butnoGRPOhints_afterdedupandidfix_multitemp_run1/metrics_temp0p4/metrics_combined_training.json.
Repository
Training code: SSL_research (commit: 2fe308cf27581b0dcb65c8aa51697d0f85db4575)
- Downloads last month
- -