GBaker/MedQA-USMLE-4-options-hf
Viewer • Updated • 12.7k • 14k • 24
How to use katsukiono/qwen3-4b-medmcqa-klmvd-lora with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="katsukiono/qwen3-4b-medmcqa-klmvd-lora")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("katsukiono/qwen3-4b-medmcqa-klmvd-lora", device_map="auto")How to use katsukiono/qwen3-4b-medmcqa-klmvd-lora with PEFT:
Task type is invalid.
How to use katsukiono/qwen3-4b-medmcqa-klmvd-lora with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "katsukiono/qwen3-4b-medmcqa-klmvd-lora"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "katsukiono/qwen3-4b-medmcqa-klmvd-lora",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/katsukiono/qwen3-4b-medmcqa-klmvd-lora
How to use katsukiono/qwen3-4b-medmcqa-klmvd-lora with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "katsukiono/qwen3-4b-medmcqa-klmvd-lora" \
--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": "katsukiono/qwen3-4b-medmcqa-klmvd-lora",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "katsukiono/qwen3-4b-medmcqa-klmvd-lora" \
--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": "katsukiono/qwen3-4b-medmcqa-klmvd-lora",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use katsukiono/qwen3-4b-medmcqa-klmvd-lora with Docker Model Runner:
docker model run hf.co/katsukiono/qwen3-4b-medmcqa-klmvd-lora
Adapter type: LoRA (PEFT)
Base model: Qwen/Qwen3-4B
Task: Medical multiple-choice reasoning (MedMCQA → KD/Distill, Bench=MedQA)
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base_id = "Qwen/Qwen3-4B"
adapter_id = "katsukiono/qwen3-4b-medmcqa-klmvd-lora"
tok = AutoTokenizer.from_pretrained(base_id, use_fast=True)
base = AutoModelForCausalLM.from_pretrained(base_id, trust_remote_code=True, dtype="auto", device_map="auto")
model = PeftModel.from_pretrained(base, adapter_id)
# generate
prompt = "Question:\nA 65-year-old woman ...\nOptions:\nA. ...\nB. ...\nC. ...\nD. ...\nAnswer:"
out = model.generate(**tok(prompt, return_tensors="pt").to(model.device), max_new_tokens=64)
print(tok.decode(out[0], skip_special_tokens=True))
o_proj, up_proj, gate_proj, down_proj