Instructions to use FreedomIntelligence/HuatuoGPT-Vision-2-27B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FreedomIntelligence/HuatuoGPT-Vision-2-27B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="FreedomIntelligence/HuatuoGPT-Vision-2-27B") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("FreedomIntelligence/HuatuoGPT-Vision-2-27B") model = AutoModelForMultimodalLM.from_pretrained("FreedomIntelligence/HuatuoGPT-Vision-2-27B", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use FreedomIntelligence/HuatuoGPT-Vision-2-27B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "FreedomIntelligence/HuatuoGPT-Vision-2-27B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FreedomIntelligence/HuatuoGPT-Vision-2-27B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/FreedomIntelligence/HuatuoGPT-Vision-2-27B
- SGLang
How to use FreedomIntelligence/HuatuoGPT-Vision-2-27B 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 "FreedomIntelligence/HuatuoGPT-Vision-2-27B" \ --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": "FreedomIntelligence/HuatuoGPT-Vision-2-27B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "FreedomIntelligence/HuatuoGPT-Vision-2-27B" \ --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": "FreedomIntelligence/HuatuoGPT-Vision-2-27B", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use FreedomIntelligence/HuatuoGPT-Vision-2-27B with Docker Model Runner:
docker model run hf.co/FreedomIntelligence/HuatuoGPT-Vision-2-27B
โก Introduction
HuatuoGPT-Vision-2-27B is a medical vision-language model in the HuatuoGPT-Vision-2 series. It is built on Qwen3.8-27B and keeps the architecture, tokenizer, and chat template of the base model.
It follows the two-stage recipe of HuatuoGPT-Vision-2:
- Medical multimodal pre-training on PubMedVision-Plus, large-scale medical image-caption pairs from PubMed, to inject medical visual knowledge.
- Reinforcement learning on PubMedVision-RL, with verifiable rewards for multiple-choice questions and rubric rewards from HuatuoGPT-Vision-2-Grader for open-ended questions, to elicit medical vision capabilities.
๐ง Thinking on or off. Like Qwen3.8-27B, the model reasons step by step inside <think>...</think> by default. Set enable_thinking=False to get a direct answer without the thinking part.
๐จโโ๏ธ Model
| Model | Base model | Thinking | Hugging Face |
|---|---|---|---|
| HuatuoGPT-Vision-2-27B | Qwen3.8-27B | On (default) / Off | FreedomIntelligence/HuatuoGPT-Vision-2-27B |
| HuatuoGPT-Vision-2-8B | Qwen3-VL-8B-Instruct | No thinking | FreedomIntelligence/HuatuoGPT-Vision-2-8B |
| HuatuoGPT-Vision-2-Grader | Qwen3-VL-8B-Instruct | No thinking | FreedomIntelligence/HuatuoGPT-Vision-2-Grader |
The weights are stored in BF16 (about 55 GB). The model can be used exactly like Qwen3.8-27B, so any framework that supports Qwen3.8 also supports this model. The MTP (multi-token prediction) layer is included for speculative decoding.
๐ Quick start with Transformers
Use a recent version of transformers that supports Qwen3.8.
from transformers import AutoModelForImageTextToText, AutoProcessor
model_id = "FreedomIntelligence/HuatuoGPT-Vision-2-27B"
processor = AutoProcessor.from_pretrained(model_id)
model = AutoModelForImageTextToText.from_pretrained(model_id, dtype="auto", device_map="auto").eval()
messages = [{"role": "user", "content": [
{"type": "image", "image": "chest_xray.jpg"}, # local path, URL, or PIL image
{"type": "text", "text": "What are the main findings in this chest X-ray?"},
]}]
inputs = processor.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_dict=True,
return_tensors="pt",
enable_thinking=True, # set to False to answer without thinking
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=8192)
print(processor.decode(outputs[0, inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
With thinking on, the output has the form reasoning</think>\n\nanswer (the opening <think> is part of the prompt). Take the text after </think> as the final answer.
๐ฅ๏ธ Serving with vLLM or SGLang
vllm serve FreedomIntelligence/HuatuoGPT-Vision-2-27B --tensor-parallel-size 2 --max-model-len 32768 --reasoning-parser qwen3 --port 30000
# or
python -m sglang.launch_server --model-path FreedomIntelligence/HuatuoGPT-Vision-2-27B --tp 2 --context-length 32768 --reasoning-parser qwen3 --port 30000
To speed up decoding with MTP speculative decoding, add these flags to the SGLang command:
--speculative-algorithm NEXTN --speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4
For vLLM, follow the MTP settings in the Qwen3.8 recipe.
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:30000/v1", api_key="EMPTY")
messages = [{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": "https://example.com/ct_scan.png"}},
{"type": "text", "text": "Describe the abnormality in this CT image."},
]}]
# Thinking mode (default)
response = client.chat.completions.create(
model="FreedomIntelligence/HuatuoGPT-Vision-2-27B",
messages=messages,
max_tokens=8192,
)
print(response.choices[0].message.content)
# Non-thinking mode
response = client.chat.completions.create(
model="FreedomIntelligence/HuatuoGPT-Vision-2-27B",
messages=messages,
max_tokens=4096,
extra_body={"chat_template_kwargs": {"enable_thinking": False}},
)
print(response.choices[0].message.content)
โ ๏ธ Disclaimer
HuatuoGPT-Vision-2 is intended for academic research only. It must not be used for diagnosis, treatment, triage, or any other clinical decision. The model can produce incorrect or fabricated findings.
๐ฉบ HuatuoGPT Series
- HuatuoGPT: Taming Language Models to Be a Doctor
- HuatuoGPT-II: One-stage Training for Medical Adaptation of LLMs
- HuatuoGPT-Vision: Injecting Medical Visual Knowledge into Multimodal LLMs at Scale
- HuatuoGPT-o1: Towards Medical Complex Reasoning with LLMs
- HuatuoGPT-3: OnePO: Direct One-stage Policy Optimization for SFT-free Domain Adaptation
- HuatuoGPT-Vision-2: Incentivizing Medical Vision Capabilities from Large-Scale Multimodal Pre-training
๐ Citation
@inproceedings{chen2026incentivizing,
title={Incentivizing Medical Vision Capabilities from Large-Scale Multimodal Pre-training},
author={Chen, Junying and Cai, Zhenyang and Yang, Yunjin and Cai, Kunyuan and Wang, Rongsheng and Wang, Xidong and Yu, Geyang and Feng, Xiangyi and Wang, Benyou},
booktitle={The Fortieth Annual Conference on Neural Information Processing Systems},
year={2026}
}
- Downloads last month
- 84