Instructions to use matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning") model = AutoModelForCausalLM.from_pretrained("matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning", 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 matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning
- SGLang
How to use matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning 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 "matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning" \ --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": "matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning", "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 "matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning" \ --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": "matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning", max_seq_length=2048, ) - Docker Model Runner
How to use matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning with Docker Model Runner:
docker model run hf.co/matthewchung74/Qwen2.5_3B-GRPO-medical-reasoning
Qwen2.5 3B GRPO Medical Reasoning Model
A fine-tuned version of Qwen2.5 3B Instruct model using Generalized Reinforcement Policy Optimization (GRPO) for medical reasoning tasks. This model is intended for education purposes only and not intended as medical advice.
Model Details
Model Description
This model is a fine-tuned version of Qwen2.5 3B Instruct, optimized for medical reasoning tasks using the Unsloth library and GRPO algorithm. It was trained on the FreedomIntelligence/medical-o1-reasoning-SFT dataset and incorporates custom reward functions for semantic correctness and perplexity.
- Developed by: Matthew Chung
- Model type: Transformer-based language model
- Language(s) (NLP): English
- License: Apache 2.0
- Finetuned from model: Qwen/Qwen2.5-3B-Instruct
Model Sources
- Repository: Qwen2.5_3B_GRPO
- Base Model: Qwen2.5-3B-Instruct
Uses
Direct Use
This model is intended for education purposes only and not intended as providing medical advice.
Downstream Use
This model is intended for education purposes only and not intended as providing medical advice.
Out-of-Scope Use
Not intended for:
- Direct medical diagnosis
- Treatment recommendations
- High-stakes medical decision making without human oversight
Bias, Risks, and Limitations
- May generate incorrect or misleading medical information
- Limited to the scope of the training data
- Potential biases from the original dataset
Recommendations
- Always verify outputs with medical professionals
- Use with caution in clinical settings
- Monitor for potential biases in responses
How to Get Started with the Model
- Refer to Github Repository
Training Details
Training Data
- Dataset: FreedomIntelligence/medical-o1-reasoning-SFT
- Training Samples: 25,117
- Validation Samples: 127
Training Procedure
Training Hyperparameters
- Learning Rate: 5e-6
- Batch Size: 1
- Gradient Accumulation Steps: 4
- Max Sequence Length: 1024
- LoRA Rank: 64
- Training Steps: 1000
- Precision: 4-bit quantization
Speeds, Sizes, Times
- Training Hardware: NVIDIA RTX 3090 (Runpod)
- Training Time: ~14 hours
- Model Size: 3B parameters
Evaluation
Testing Data, Factors & Metrics
Testing Data
Same as training data (FreedomIntelligence/medical-o1-reasoning-SFT)
Metrics
- Semantic correctness
- Perplexity
- Tag presence accuracy
Results
Final training metrics:
- Loss: 0.001300
- Semantic Score: 0.630995
- Perplexity: 266.149998
Environmental Impact
- Hardware Type: NVIDIA RTX 3090
- Hours used: ~14
- Cloud Provider: Runpod
- Compute Region: US-West
- Carbon Emitted: Estimated 0.5 kg CO2
Technical Specifications
Model Architecture and Objective
- Architecture: Transformer-based
- Objective: Causal language modeling with GRPO optimization
Compute Infrastructure
Hardware
- NVIDIA RTX 3090 GPU
- 24GB VRAM
Software
- Unsloth
- PyTorch
- Hugging Face Transformers
- vLLM
- Downloads last month
- 14