Image-Text-to-Text
Transformers
Safetensors
gemma3
Generated from Trainer
sft
trl
conversational
text-generation-inference
Instructions to use swap-uniba/user_gemma_3_27b_it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use swap-uniba/user_gemma_3_27b_it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="swap-uniba/user_gemma_3_27b_it") 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 AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("swap-uniba/user_gemma_3_27b_it") model = AutoModelForMultimodalLM.from_pretrained("swap-uniba/user_gemma_3_27b_it", device_map="auto") 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?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use swap-uniba/user_gemma_3_27b_it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "swap-uniba/user_gemma_3_27b_it" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "swap-uniba/user_gemma_3_27b_it", "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/swap-uniba/user_gemma_3_27b_it
- SGLang
How to use swap-uniba/user_gemma_3_27b_it 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 "swap-uniba/user_gemma_3_27b_it" \ --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": "swap-uniba/user_gemma_3_27b_it", "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 "swap-uniba/user_gemma_3_27b_it" \ --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": "swap-uniba/user_gemma_3_27b_it", "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 swap-uniba/user_gemma_3_27b_it with Docker Model Runner:
docker model run hf.co/swap-uniba/user_gemma_3_27b_it
| # config.yaml | |
| # General settings for the training run | |
| general: | |
| output_dir: "/leonardo_scratch/large/userexternal/apetruzz/ale_priv/SpecialIssue/results/user_gemma_3_27b_it" # Directory to save the final model adapters | |
| # Model configuration | |
| model: | |
| name: "/leonardo_scratch/large/userexternal/apetruzz/ale_priv/base_models/gemma-3-27b-it" # Base model from Hugging Face Hub | |
| max_seq_length: 2048 # Maximum sequence length for the tokenizer and model | |
| trust_remote_code: true | |
| chat_template_file: "/leonardo_work/IscrC_SYMBREC/ale/UserSimTraining/data/chat_template.jinja" | |
| # Dataset configuration | |
| dataset: | |
| name: "/leonardo_work/IscrC_SYMBREC/ale/UserSimTraining/data/all_processed_prompts.jsonl" # Dataset from Hugging Face Hub or local path | |
| text_field: "prompt" # The name of the column in the dataset that contains the text | |
| # PEFT (LoRA) configuration | |
| peft_config: | |
| lora_alpha: 32 | |
| lora_dropout: 0.1 | |
| r: 64 | |
| bias: "none" | |
| task_type: "CAUSAL_LM" | |
| target_modules: | |
| - "q_proj" | |
| - "k_proj" | |
| - "v_proj" | |
| - "o_proj" | |
| # SFTTrainer-specific arguments | |
| trainer_args: | |
| packing: false | |
| # Logging configuration | |
| logging: | |
| use_wandb: false # Set to true to enable Weights & Biases logging | |
| # Hugging Face TrainingArguments | |
| # See https://huggingface.co/docs/transformers/main_classes/trainer#transformers.TrainingArguments | |
| training_args: | |
| num_train_epochs: 5 | |
| per_device_train_batch_size: 8 | |
| gradient_accumulation_steps: 1 | |
| optim: "adamw_torch" | |
| logging_steps: 25 | |
| learning_rate: 0.0002 # 2e-4 | |
| weight_decay: 0.001 | |
| fp16: false | |
| bf16: true | |
| max_grad_norm: 0.3 | |
| max_steps: -1 | |
| warmup_ratio: 0.03 | |
| group_by_length: true | |
| lr_scheduler_type: "constant" | |
| #evaluation_strategy: "epoch" | |
| save_strategy: "epoch" | |