Instructions to use google/paligemma-3b-mix-224 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/paligemma-3b-mix-224 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="google/paligemma-3b-mix-224")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("google/paligemma-3b-mix-224") model = AutoModelForMultimodalLM.from_pretrained("google/paligemma-3b-mix-224", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use google/paligemma-3b-mix-224 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "google/paligemma-3b-mix-224" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "google/paligemma-3b-mix-224", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/google/paligemma-3b-mix-224
- SGLang
How to use google/paligemma-3b-mix-224 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 "google/paligemma-3b-mix-224" \ --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": "google/paligemma-3b-mix-224", "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 "google/paligemma-3b-mix-224" \ --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": "google/paligemma-3b-mix-224", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use google/paligemma-3b-mix-224 with Docker Model Runner:
docker model run hf.co/google/paligemma-3b-mix-224
Distributed Finetuning
Hi,
Would you please write me how I can do distributed Finetuning with two PCs each has 4090 GPU? I think Data parallelization is good. If you can share the code, I appreciate it.
Thanks.
Hi @pooyahug
JAX's support for Single-Program Multi-Data (SPMD) programming allows you to train models efficiently across multiple devices.
Resources to Get Started:
- Fine-tuning PaliGemma with JAX and Flax:
You can explore a tutorial tailored to fine-tuning the PaliGemma model using JAX and Flax here. This will guide you through the setup and fundamental concepts of fine-tuning using these tools. - Introduction to Parallel Programming in JAX:
To leverage data parallelism, refer to the Introduction to Parallel Programming Guide. This tutorial covers SPMD techniques in JAX for running computations in parallel across multiple GPUs.
Thanks Selam,
I already saw this tutorial but it was complicated to run it on two PCs each has 4090 GPU. I think it is multi node distributed training. I searched about it with jax and found that jax doesn't support this way of distributed training. I have a local network and these two PCs are servers. I can define one of them as master with specific IP and the other as slave. I ran huggingface finetuning code with my custom dataset on 1 PC but it is too slow. I would like to distribute it on two PCs to speedup. I want help to change my code to be suitable for multi node distributed training using huggingface code.
If you want I can share my huggingface finetuning code running on 1 PC.
Thanks.