Text Generation
Transformers
Safetensors
English
Chinese
Malay
qwen2
redflag
medical
extraction
qwen2.5
LoRA-merged
conversational
text-generation-inference
Instructions to use ningpy/redflag-detection-V4.2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ningpy/redflag-detection-V4.2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ningpy/redflag-detection-V4.2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ningpy/redflag-detection-V4.2") model = AutoModelForCausalLM.from_pretrained("ningpy/redflag-detection-V4.2", 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 ningpy/redflag-detection-V4.2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ningpy/redflag-detection-V4.2" # 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/redflag-detection-V4.2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ningpy/redflag-detection-V4.2
- SGLang
How to use ningpy/redflag-detection-V4.2 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/redflag-detection-V4.2" \ --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/redflag-detection-V4.2", "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/redflag-detection-V4.2" \ --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/redflag-detection-V4.2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ningpy/redflag-detection-V4.2 with Docker Model Runner:
docker model run hf.co/ningpy/redflag-detection-V4.2
Redflag Detection V4.2 (V20g, strict 59-rule spec compliance)
Fine-tuned from Qwen2.5-7B-Instruct for medical red-flag extraction. Strict compliance with 2026-08 Medical Advisory "Red Flad_New" spec (59 rules).
V4.2 vs V4.1
V4.1 (V20d) included 6 "extension" rules (Row 60-65) and 7 symptoms not in the official 59-rule spec (testicular_torsion, pyelonephritis, PID, angle-closure glaucoma, cauda equina, PPH). These were removed in V4.2 to comply with Medical Advisory scope.
- Closed symptom set: 96 → 89 items (dropped 7 orphaned)
- Rule engine: 65 → 59 rules
- Prompt v11 (was v10)
- Training data: sanitized (dropped 81 samples of orphan-only cases + 160 orphan symptom mentions from labels) + 31 negative reinforcement samples
- Fix:
is_maleschema hallucination remains 0
Performance (val 269, strict)
| V4.0 (V20c) | V4.1 (V20d) | V4.2 (V20g) | |
|---|---|---|---|
| Exact Match | 89.2% | 87.0% | 89.6% |
| Precision | 0.918 | 0.901 | 0.921 |
| Recall | 0.749 | 0.786 | 0.779 |
| F1 | 0.825 | 0.839 | 0.844 |
Clinical-fair (SUSPECTED = TP for recall)
- Precision: 0.771
- Recall: 0.865
- F1: 0.815
Notes
- Orphan symptom residual: 7/269 model outputs mention removed symptoms. Engine ignores them (0 flag impact). Downstream systems can safely strip them or ignore.
- V4.2 covers exactly what's in the official spec. Coverage gaps for testicular torsion, angle-closure glaucoma, cauda equina, PPH require Medical Advisory spec expansion (see git history commit b61a4e9/cd5b628 for the extension logic that was removed).
Usage
python3 -m vllm.entrypoints.openai.api_server \
--model ningpy/redflag-detection-V4.2 \
--served-model-name redflag \
--dtype float16
Pair with the 59-rule V20 engine (redflag_scripts/v20/rule_engine_v20.py).
Training
- 3766 samples (V20f 3735 + patch20e_neg 31)
- LoRA r=32 alpha=64, 7 target projections
- 3 epochs @ 2e-5, seq len 1900, 8×V100 DDP
- Downloads last month
- -