Instructions to use Lexius/Phi-3.5-vision-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Lexius/Phi-3.5-vision-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Lexius/Phi-3.5-vision-instruct", 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("Lexius/Phi-3.5-vision-instruct", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Lexius/Phi-3.5-vision-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Lexius/Phi-3.5-vision-instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Lexius/Phi-3.5-vision-instruct", "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/Lexius/Phi-3.5-vision-instruct
- SGLang
How to use Lexius/Phi-3.5-vision-instruct 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 "Lexius/Phi-3.5-vision-instruct" \ --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": "Lexius/Phi-3.5-vision-instruct", "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 "Lexius/Phi-3.5-vision-instruct" \ --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": "Lexius/Phi-3.5-vision-instruct", "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 Lexius/Phi-3.5-vision-instruct with Docker Model Runner:
docker model run hf.co/Lexius/Phi-3.5-vision-instruct
Again the similar error
File "/home/jovyan/.cache/huggingface/modules/transformers_modules/Lexius/Phi-3.5-vision-instruct/88fa59eca4f9b856a9d9ef58b14b32d2d80b0973/modeling_phi3_v.py", line 1417, in forward
past_key_values_length = past_key_values.get_usable_length(seq_length)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'DynamicCache' object has no attribute 'get_usable_length'. Did you mean: 'get_seq_length'?
File "/home/jovyan/.cache/huggingface/modules/transformers_modules/Lexius/Phi-3.5-vision-instruct/88fa59eca4f9b856a9d9ef58b14b32d2d80b0973/modeling_phi3_v.py", line 786, in forward
kv_seq_len += past_key_value.get_usable_length(kv_seq_len, self.layer_idx)
File "/home/jovyan/.cache/huggingface/modules/transformers_modules/Lexius/Phi-3.5-vision-instruct/88fa59eca4f9b856a9d9ef58b14b32d2d80b0973/modeling_phi3_v.py", line 1660, in prepare_inputs_for_generation
past_length = past_key_values.seen_tokens
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'DynamicCache' object has no attribute 'seen_tokens'
Sorry for the delay, I somehow didn't get any notification about this issue...
These are different errors. The original error was DynamicCache' object has no attribute 'get_max_length'
The new errors are:
AttributeError: 'DynamicCache' object has no attribute 'get_usable_length'. Did you mean: 'get_seq_length'?AttributeError: 'DynamicCache' object has no attribute 'seen_tokens'
I'll fix it... thanks for reporting.
have these new errors like 'seen_tokens' been fixed?
ive been having trubles with the compatibiliti of transformers,
DynamicCache' object has no attribute 'get_max_length'
NameError: name 'use_legacy_cache' is not defined
Hello
This should be fixed in https://huggingface.co/Lexius/Phi-3.5-vision-instruct/discussions/2
Thanks @lerignoux !