Instructions to use Qwen/Qwen-VL-Chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwen/Qwen-VL-Chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Qwen/Qwen-VL-Chat", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-VL-Chat", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Qwen/Qwen-VL-Chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Qwen/Qwen-VL-Chat" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Qwen/Qwen-VL-Chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Qwen/Qwen-VL-Chat
- SGLang
How to use Qwen/Qwen-VL-Chat 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 "Qwen/Qwen-VL-Chat" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Qwen/Qwen-VL-Chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "Qwen/Qwen-VL-Chat" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Qwen/Qwen-VL-Chat", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Qwen/Qwen-VL-Chat with Docker Model Runner:
docker model run hf.co/Qwen/Qwen-VL-Chat
Coupling specific tasks with LM-attn poses potential risks of LLM degradation.
After testing the Vision part from this repo with the Qwen-7B-Chat weights, it was observed that certain tasks such as Chinese OCR are coupled with the attention mechanism of this (VL-Chat) specific version of LLM, while other tasks like English OCR, general Chinese, and English VQA are not coupled with the LLM (based on Qwen-7B-Base).
It can be inferred that in order to achieve better scores in certain tasks, some tasks were trained on the LLM, and there is reason to believe that the LLM has degraded. I would like you to examine the benchmark test results of the LLM.
Hi @JosephusCheung , thanks for your point. We have fine-tuned the LLM during the training of Qwen-VL, so the LLM weights are different from Qwen-7B & Chat. There is the potential that the fine-tuned LLM has degraded. We will examine the benchmark test results of the fine-tuned LLM sonn.
If possible, I would like to consider incorporating these changes by using adapters for on-the-fly loading during image reasoning only, in order to modify the attention weights of LLM. I believe that from a practical standpoint, this can be done without affecting the effectiveness of text reasoning. If there is no official implementation available, I would also consider implementing it myself.
Sure! You can use LoRA or other adapter techniques. Due to the computation budget, we don't implement it. You can try it yourself and feel free to contact us with any issue.