Image-Text-to-Text
Transformers
Safetensors
PyTorch
hulumed_qwen2
text-generation
medical
multimodal
vision-language-model
image-to-text
video-understanding
3d-understanding
qwen
conversational
custom_code
Instructions to use ZJU-AI4H/Hulu-Med-32B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ZJU-AI4H/Hulu-Med-32B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ZJU-AI4H/Hulu-Med-32B", trust_remote_code=True) 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)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("ZJU-AI4H/Hulu-Med-32B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ZJU-AI4H/Hulu-Med-32B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ZJU-AI4H/Hulu-Med-32B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ZJU-AI4H/Hulu-Med-32B", "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/ZJU-AI4H/Hulu-Med-32B
- SGLang
How to use ZJU-AI4H/Hulu-Med-32B 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 "ZJU-AI4H/Hulu-Med-32B" \ --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": "ZJU-AI4H/Hulu-Med-32B", "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 "ZJU-AI4H/Hulu-Med-32B" \ --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": "ZJU-AI4H/Hulu-Med-32B", "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 ZJU-AI4H/Hulu-Med-32B with Docker Model Runner:
docker model run hf.co/ZJU-AI4H/Hulu-Med-32B
'image_token' is undefined
#5
by dddwzl3703 - opened
followed vLLM Installation instruction, tested with official example:
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "ZJU-AI4H/Hulu-Med-32B",
"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"
}
}
]
}
]
}'
and get:
(APIServer pid=2750956) INFO: 127.0.0.1:44528 - "POST /v1/chat/completions HTTP/1.1" 400 Bad Request
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] An error occurred in `transformers` while applying chat template
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] Traceback (most recent call last):
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] File "/home/user/workspace/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 1764, in apply_hf_chat_template
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] return tokenizer.apply_chat_template(
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] File "/home/user/workspace/vllm/.venv/lib/python3.12/site-packages/transformers/tokenization_utils_base.py", line 1667, in apply_chat_template
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] rendered_chat, generation_indices = render_jinja_template(
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] ^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] File "/home/user/workspace/vllm/.venv/lib/python3.12/site-packages/transformers/utils/chat_template_utils.py", line 539, in render_jinja_template
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] rendered_chat = compiled_template.render(
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] ^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] File "/home/user/workspace/vllm/.venv/lib/python3.12/site-packages/jinja2/environment.py", line 1295, in render
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] self.environment.handle_exception()
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] File "/home/user/workspace/vllm/.venv/lib/python3.12/site-packages/jinja2/environment.py", line 942, in handle_exception
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] raise rewrite_traceback_stack(source=source)
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] File "<template>", line 29, in top-level template code
(APIServer pid=2750956) ERROR 02-06 11:03:09 [chat_utils.py:1777] jinja2.exceptions.UndefinedError: 'image_token' is undefined
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] Error in preprocessing prompt inputs
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] Traceback (most recent call last):
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] File "/home/user/workspace/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 1764, in apply_hf_chat_template
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] return tokenizer.apply_chat_template(
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] File "/home/user/workspace/vllm/.venv/lib/python3.12/site-packages/transformers/tokenization_utils_base.py", line 1667, in apply_chat_template
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] rendered_chat, generation_indices = render_jinja_template(
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] ^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] File "/home/user/workspace/vllm/.venv/lib/python3.12/site-packages/transformers/utils/chat_template_utils.py", line 539, in render_jinja_template
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] rendered_chat = compiled_template.render(
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] ^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] File "/home/user/workspace/vllm/.venv/lib/python3.12/site-packages/jinja2/environment.py", line 1295, in render
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] self.environment.handle_exception()
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] File "/home/user/workspace/vllm/.venv/lib/python3.12/site-packages/jinja2/environment.py", line 942, in handle_exception
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] raise rewrite_traceback_stack(source=source)
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] File "<template>", line 29, in top-level template code
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] jinja2.exceptions.UndefinedError: 'image_token' is undefined
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258]
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] The above exception was the direct cause of the following exception:
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258]
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] Traceback (most recent call last):
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] File "/home/user/workspace/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/openai/serving_chat.py", line 236, in create_chat_completion
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] ) = await self._preprocess_chat(
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] File "/home/user/workspace/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/openai/serving_engine.py", line 1134, in _preprocess_chat
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] request_prompt = apply_hf_chat_template(
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] ^^^^^^^^^^^^^^^^^^^^^^^
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] File "/home/user/workspace/vllm/.venv/lib/python3.12/site-packages/vllm/entrypoints/chat_utils.py", line 1780, in apply_hf_chat_template
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] raise ValueError(str(e)) from e
(APIServer pid=2750956) ERROR 02-06 11:03:09 [serving_chat.py:258] ValueError: 'image_token' is undefined