Text Generation
Transformers
Safetensors
PEFT
English
qwen3
medical
llm
thinking-model
entity-extraction
relation-extraction
lora
conversational
text-generation-inference
Instructions to use xingqiang/Medical-NER-Qwen-4B-Thinking-merged with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use xingqiang/Medical-NER-Qwen-4B-Thinking-merged with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="xingqiang/Medical-NER-Qwen-4B-Thinking-merged") 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("xingqiang/Medical-NER-Qwen-4B-Thinking-merged") model = AutoModelForCausalLM.from_pretrained("xingqiang/Medical-NER-Qwen-4B-Thinking-merged", 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]:])) - PEFT
How to use xingqiang/Medical-NER-Qwen-4B-Thinking-merged with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use xingqiang/Medical-NER-Qwen-4B-Thinking-merged with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "xingqiang/Medical-NER-Qwen-4B-Thinking-merged" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xingqiang/Medical-NER-Qwen-4B-Thinking-merged", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/xingqiang/Medical-NER-Qwen-4B-Thinking-merged
- SGLang
How to use xingqiang/Medical-NER-Qwen-4B-Thinking-merged 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 "xingqiang/Medical-NER-Qwen-4B-Thinking-merged" \ --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": "xingqiang/Medical-NER-Qwen-4B-Thinking-merged", "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 "xingqiang/Medical-NER-Qwen-4B-Thinking-merged" \ --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": "xingqiang/Medical-NER-Qwen-4B-Thinking-merged", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use xingqiang/Medical-NER-Qwen-4B-Thinking-merged with Docker Model Runner:
docker model run hf.co/xingqiang/Medical-NER-Qwen-4B-Thinking-merged
Medical-NER-Qwen-4B-Thinking
Model Description
This is a fine-tuned medical LLM based on Qwen3-4B-Thinking, specialized for medical entity and relationship extraction.
Model Details
- Base Model: unsloth/Qwen3-4B-Thinking-2507
- Fine-tuning Method: LoRA (Low-Rank Adaptation)
- Domain: Medical Literature Analysis
- Tasks: Entity Recognition, Relationship Extraction
- Language: English
Performance Metrics
| Metric | Entity Extraction | Relationship Extraction |
|---|---|---|
| Precision | 0.000 | 0.000 |
| Recall | 0.000 | 0.000 |
| F1-Score | 0.000 | 0.000 |
Usage
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-3B-Thinking",
torch_dtype="auto",
device_map="auto"
)
# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "xingqiang/Medical-NER-Qwen-4B-Thinking-merged")
tokenizer = AutoTokenizer.from_pretrained("xingqiang/Medical-NER-Qwen-4B-Thinking-merged")
# Generate medical analysis
text = "Hepatitis C virus causes chronic liver infection."
messages = [
{"role": "user", "content": f"Extract medical entities and relationships from: {text}"}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=256)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(result)
- Downloads last month
- 7