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.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ningpy/redflag-detection-V4.0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ningpy/redflag-detection-V4.0") 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.0") model = AutoModelForCausalLM.from_pretrained("ningpy/redflag-detection-V4.0", 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.0 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.0" # 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.0", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ningpy/redflag-detection-V4.0
- SGLang
How to use ningpy/redflag-detection-V4.0 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.0" \ --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.0", "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.0" \ --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.0", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ningpy/redflag-detection-V4.0 with Docker Model Runner:
docker model run hf.co/ningpy/redflag-detection-V4.0
Redflag Detection V4.0 (V20 Red Flad_New spec)
Medical red-flag symptom extraction model fine-tuned from Qwen2.5-7B-Instruct. Aligned with 2026-08 Medical Advisory "Red Flad_New" specification: 59 rules, strict IF+AND semantics.
Extraction Schema
- 96 atomic symptoms (V17 base 78 + 18 new: coughing_blood, collapse, pale_cold_clammy_skin, mottled_skin, very_drowsy, reduced_responsiveness, no_urine, sunken_eyes, dry_mouth, high_pitched_cry, blue_grey_color, difficulty_swallowing, abnormal_behavior, deep_rapid_breathing, palpitations, eye_injury, neck_swelling, severe_weakness)
- New severity modifiers: has_severe_complication, is_life_threatening, is_recurring, severity_level
- New context flags: smoke_inhalation, chemical_exposure, venomous_bite, electrical_injury, cold_exposure, drowning, serious_assault
- Population gates: is_pregnant, is_postpartum, is_elderly, is_child, is_baby, is_immunocompromised, has_diabetes, has_asthma, age_band
Performance (val 269, strict)
- Exact Match: 89.2%
- Precision: 0.918
- Recall: 0.749
- F1: 0.825
Performance (val 269, clinical-fair, SUSPECTED counted for recall)
- Precision: 0.787
- Recall: 0.851
- F1: 0.818
Usage with vLLM
python3 -m vllm.entrypoints.openai.api_server \
--model ningpy/redflag-detection-V4.0 \
--served-model-name redflag \
--dtype float16
Requires the V20 rule engine (data-driven, 59 compiled rules). Extraction
output JSON is fed to engine.evaluate_rules() to produce matched_flags /
suspected_flags.
Training
- 3766 samples (V17 base 3505 + patch20 68 + patch20c 193)
- LoRA r=32 alpha=64, 7 target projections
- 3 epochs @ 2e-5, seq len 1900
- 8×V100 DDP
- Downloads last month
- -