Instructions to use xlangai/OpenCUA-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use xlangai/OpenCUA-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="xlangai/OpenCUA-7B", 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 AutoModel model = AutoModel.from_pretrained("xlangai/OpenCUA-7B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use xlangai/OpenCUA-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "xlangai/OpenCUA-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xlangai/OpenCUA-7B", "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/xlangai/OpenCUA-7B
- SGLang
How to use xlangai/OpenCUA-7B 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 "xlangai/OpenCUA-7B" \ --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": "xlangai/OpenCUA-7B", "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 "xlangai/OpenCUA-7B" \ --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": "xlangai/OpenCUA-7B", "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 xlangai/OpenCUA-7B with Docker Model Runner:
docker model run hf.co/xlangai/OpenCUA-7B
Partial fix for transformers 5.13.0
This pr addresses broken tokenization config in transformers, a variable with special tokens was renamed from additional_special_tokens to extra_special_tokens. This was supposed to happen in v5, but the code path was hidden untill changes in this pr: https://github.com/huggingface/transformers/pull/46667/changes#diff-d804e851851cdebeb8048938f1f8beec1cfa78bf7b1f06af86faa450f9d18defR818-R823
This pr (the one I'm proposing here, on hugginface) does not change the behaviour for ealier versions of transformers, while fixing it in newest one. There is another problem related to this model, which I'm trying to fix in this pr: https://github.com/vllm-project/vllm/pull/47438.
Since the transformers error occures after the vllm one, in order to reproduce it you'll have to checkout to my vllm branch, and run:
vllm serve xlangai/OpenCUA-7B --dtype bfloat16 --tensor-parallel-size 1 --max-model-len 8192 --gpu-memory-utilization 0.85 -cc '{"inductor_compile_config":{"benchmark_combo_kernel":false}}' --port 8000 --trust-remote-code --limit-mm-per-prompt '{"image": 1}'