Text Generation
Transformers
Safetensors
English
Chinese
Malay
qwen2
intent-classification
health
medical
safety
qwen2.5
LoRA-merged
conversational
text-generation-inference
Instructions to use ningpy/intent-detection-V2.4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ningpy/intent-detection-V2.4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ningpy/intent-detection-V2.4") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ningpy/intent-detection-V2.4") model = AutoModelForCausalLM.from_pretrained("ningpy/intent-detection-V2.4", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ningpy/intent-detection-V2.4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ningpy/intent-detection-V2.4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ningpy/intent-detection-V2.4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ningpy/intent-detection-V2.4
- SGLang
How to use ningpy/intent-detection-V2.4 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 "ningpy/intent-detection-V2.4" \ --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": "ningpy/intent-detection-V2.4", "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 "ningpy/intent-detection-V2.4" \ --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": "ningpy/intent-detection-V2.4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ningpy/intent-detection-V2.4 with Docker Model Runner:
docker model run hf.co/ningpy/intent-detection-V2.4
File size: 3,190 Bytes
f9f42ea | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | ---
license: apache-2.0
base_model: Qwen/Qwen2.5-7B-Instruct
tags:
- intent-classification
- health
- medical
- safety
- qwen2.5
- LoRA-merged
language:
- en
- zh
- ms
library_name: transformers
pipeline_tag: text-generation
---
# Intent Detection V2.4 (V12.10)
Health-app user intent classifier + safety router fine-tuned from Qwen2.5-7B-Instruct.
Routes user messages into 5 states: PASS, REDFLAG, BLOCK, STEER, or COEXIST (emergency + personal-dose).
## Performance (val set: 2518 samples)
| Metric | Score |
|---|---|
| **Safety F1** (REDFLAG ∪ BLOCK) | **92.3%** |
| **Multi-label EM** | **88.0%** |
| **Joint acc** (intent + all types) | **81.5%** |
| **Single-label acc** (v11-compatible projection) | **90.1%** |
| **Intent acc** | **93.5%** |
| **Coexist recall** (REDFLAG + BLOCK) | **76.2%** |
| **Parse err** | **0.16%** (of which ~half are eval-side bugs — model output is valid) |
| **REDFLAG reason_code acc** | **98.3%** |
Improvements vs V11 (single-label):
- Safety F1: 90.9% → **92.3%** (+1.4pp)
- REDFLAG F1: 90.0% → **94.1%** (+4.1pp)
- **New multi-label capability**: 76.2% coexist recall (v11 was 0%)
## Output Schema (V12.10 flat)
6 fixed keys, deterministic order:
```json
{
"intent": "HA|HCN|MT|PI|OTHER",
"redflag": true|false,
"redflag_code": "RF-1_GENERAL|RF-2_PEDIATRIC|RF-3_OBSTETRIC|RF-4_ELDERLY|RF-5_IMMUNOCOMP|\"\"",
"block": "BLOCK_HARD|STEER_SOFT|PASS|NONE",
"block_code": "OOS_H_*|OOS_S_*|PASS_*|\"\"",
"entities": {
"drugs": ["<verbatim from user text>"],
"diseases": ["..."],
"symptoms": ["..."]
}
}
```
Entities are **verbatim** substrings of the user message (no translation/normalization).
## 5 Valid State Combinations
| State | redflag | block | Use case |
|---|---|---|---|
| PASS | false | PASS | Normal health knowledge Q |
| REDFLAG only | true | NONE | Emergency without personal-dose Q |
| BLOCK only | false | BLOCK_HARD | Personal action / off-topic |
| STEER only | false | STEER_SOFT | Personal clinical judgment |
| **COEXIST** | true | BLOCK_HARD | Emergency + personal-dose |
## Training data
- 54,404 samples (English + Chinese + Bruneian Malay)
- Base 27K + STEER×3 + coexist×8 + patch13×3 (targeted narrow rules) + patch16×5 (anti-drift + narrow)
- 57.1% samples have non-empty entities (GPT-4o back-filled)
## Usage with vLLM
```bash
python -m vllm.entrypoints.openai.api_server \
--model ningpy/intent-detection-V2.4 \
--served-model-name intent \
--dtype float16 \
--port 8001
```
## Client sample
See https://git.evyd.tech/peiyan.ning/intent-model-v12/tree/main/sample for a
Python client with routing + response templates.
Recommended request settings:
- `temperature: 0.0`
- `max_tokens: 200`
- `stop: []` (rely on model's natural `<|im_end|>`)
## Downstream routing
| Model output | Action |
|---|---|
| `redflag=true, block="BLOCK_HARD"` | Emergency guidance + refuse dose advice |
| `redflag=true, block="NONE"` | Emergency guidance |
| `redflag=false, block="BLOCK_HARD"` | Refuse + refer to doctor |
| `redflag=false, block="STEER_SOFT"` | Soft guide to consultation |
| `redflag=false, block="PASS"` | Normal RAG/LLM answer |
|