Image-Text-to-Text
Transformers
Safetensors
gemma4
fp4
vllm
llm-compressor
compressed-tensors
conversational
8-bit precision
Instructions to use RedHatAI/gemma-4-31B-it-NVFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RedHatAI/gemma-4-31B-it-NVFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="RedHatAI/gemma-4-31B-it-NVFP4") 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, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("RedHatAI/gemma-4-31B-it-NVFP4") model = AutoModelForImageTextToText.from_pretrained("RedHatAI/gemma-4-31B-it-NVFP4") 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
- vLLM
How to use RedHatAI/gemma-4-31B-it-NVFP4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RedHatAI/gemma-4-31B-it-NVFP4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHatAI/gemma-4-31B-it-NVFP4", "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/RedHatAI/gemma-4-31B-it-NVFP4
- SGLang
How to use RedHatAI/gemma-4-31B-it-NVFP4 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 "RedHatAI/gemma-4-31B-it-NVFP4" \ --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": "RedHatAI/gemma-4-31B-it-NVFP4", "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 "RedHatAI/gemma-4-31B-it-NVFP4" \ --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": "RedHatAI/gemma-4-31B-it-NVFP4", "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 RedHatAI/gemma-4-31B-it-NVFP4 with Docker Model Runner:
docker model run hf.co/RedHatAI/gemma-4-31B-it-NVFP4
Update tokenizer_config.json
Browse files- tokenizer_config.json +22 -43
tokenizer_config.json
CHANGED
|
@@ -17,72 +17,51 @@
|
|
| 17 |
"<|video|>"
|
| 18 |
],
|
| 19 |
"image_token": "<|image|>",
|
| 20 |
-
"is_local": false,
|
| 21 |
"mask_token": "<mask>",
|
| 22 |
"model_max_length": 1000000000000000019884624838656,
|
| 23 |
-
"model_specific_special_tokens": {
|
| 24 |
-
"audio_token": "<|audio|>",
|
| 25 |
-
"boa_token": "<|audio>",
|
| 26 |
-
"boi_token": "<|image>",
|
| 27 |
-
"eoa_token": "<audio|>",
|
| 28 |
-
"eoc_token": "<channel|>",
|
| 29 |
-
"eoi_token": "<image|>",
|
| 30 |
-
"eot_token": "<turn|>",
|
| 31 |
-
"escape_token": "<|\"|>",
|
| 32 |
-
"etc_token": "<tool_call|>",
|
| 33 |
-
"etd_token": "<tool|>",
|
| 34 |
-
"etr_token": "<tool_response|>",
|
| 35 |
-
"image_token": "<|image|>",
|
| 36 |
-
"soc_token": "<|channel>",
|
| 37 |
-
"sot_token": "<|turn>",
|
| 38 |
-
"stc_token": "<|tool_call>",
|
| 39 |
-
"std_token": "<|tool>",
|
| 40 |
-
"str_token": "<|tool_response>",
|
| 41 |
-
"think_token": "<|think|>"
|
| 42 |
-
},
|
| 43 |
"pad_token": "<pad>",
|
| 44 |
"padding_side": "left",
|
| 45 |
"processor_class": "Gemma4Processor",
|
| 46 |
"response_schema": {
|
|
|
|
| 47 |
"properties": {
|
| 48 |
-
"content": {
|
| 49 |
-
"type": "string"
|
| 50 |
-
},
|
| 51 |
"role": {
|
| 52 |
"const": "assistant"
|
| 53 |
},
|
| 54 |
"thinking": {
|
| 55 |
"type": "string"
|
| 56 |
},
|
|
|
|
|
|
|
|
|
|
| 57 |
"tool_calls": {
|
|
|
|
|
|
|
| 58 |
"items": {
|
|
|
|
| 59 |
"properties": {
|
|
|
|
|
|
|
|
|
|
| 60 |
"function": {
|
|
|
|
|
|
|
| 61 |
"properties": {
|
| 62 |
-
"arguments": {
|
| 63 |
-
"additionalProperties": {},
|
| 64 |
-
"type": "object",
|
| 65 |
-
"x-parser": "gemma4-tool-call"
|
| 66 |
-
},
|
| 67 |
"name": {
|
| 68 |
"type": "string"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
}
|
| 70 |
-
}
|
| 71 |
-
"type": "object",
|
| 72 |
-
"x-regex": "call\\:(?P<name>\\w+)(?P<arguments>\\{.*\\})"
|
| 73 |
-
},
|
| 74 |
-
"type": {
|
| 75 |
-
"const": "function"
|
| 76 |
}
|
| 77 |
-
}
|
| 78 |
-
|
| 79 |
-
},
|
| 80 |
-
"type": "array",
|
| 81 |
-
"x-regex-iterator": "<\\|tool_call>(.*?)<tool_call\\|>"
|
| 82 |
}
|
| 83 |
},
|
| 84 |
-
"
|
| 85 |
-
"x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<content>(?:(?!\\<\\|tool_call\\>)(?!\\<turn\\|\\>).)+)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?:\\<turn\\|\\>)?"
|
| 86 |
},
|
| 87 |
"soc_token": "<|channel>",
|
| 88 |
"sot_token": "<|turn>",
|
|
@@ -92,4 +71,4 @@
|
|
| 92 |
"think_token": "<|think|>",
|
| 93 |
"tokenizer_class": "GemmaTokenizer",
|
| 94 |
"unk_token": "<unk>"
|
| 95 |
-
}
|
|
|
|
| 17 |
"<|video|>"
|
| 18 |
],
|
| 19 |
"image_token": "<|image|>",
|
|
|
|
| 20 |
"mask_token": "<mask>",
|
| 21 |
"model_max_length": 1000000000000000019884624838656,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
"pad_token": "<pad>",
|
| 23 |
"padding_side": "left",
|
| 24 |
"processor_class": "Gemma4Processor",
|
| 25 |
"response_schema": {
|
| 26 |
+
"type": "object",
|
| 27 |
"properties": {
|
|
|
|
|
|
|
|
|
|
| 28 |
"role": {
|
| 29 |
"const": "assistant"
|
| 30 |
},
|
| 31 |
"thinking": {
|
| 32 |
"type": "string"
|
| 33 |
},
|
| 34 |
+
"content": {
|
| 35 |
+
"type": "string"
|
| 36 |
+
},
|
| 37 |
"tool_calls": {
|
| 38 |
+
"x-regex-iterator": "<\\|tool_call>(.*?)<tool_call\\|>",
|
| 39 |
+
"type": "array",
|
| 40 |
"items": {
|
| 41 |
+
"type": "object",
|
| 42 |
"properties": {
|
| 43 |
+
"type": {
|
| 44 |
+
"const": "function"
|
| 45 |
+
},
|
| 46 |
"function": {
|
| 47 |
+
"type": "object",
|
| 48 |
+
"x-regex": "call\\:(?P<name>\\w+)(?P<arguments>\\{.*\\})",
|
| 49 |
"properties": {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
"name": {
|
| 51 |
"type": "string"
|
| 52 |
+
},
|
| 53 |
+
"arguments": {
|
| 54 |
+
"type": "object",
|
| 55 |
+
"x-parser": "gemma4-tool-call",
|
| 56 |
+
"additionalProperties": {}
|
| 57 |
}
|
| 58 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
}
|
| 60 |
+
}
|
| 61 |
+
}
|
|
|
|
|
|
|
|
|
|
| 62 |
}
|
| 63 |
},
|
| 64 |
+
"x-regex": "(\\<\\|channel\\>thought\\n(?P<thinking>.*?)\\<channel\\|\\>)?(?P<tool_calls>\\<\\|tool_call\\>.*\\<tool_call\\|\\>)?(?P<content>(?:(?!\\<turn\\|\\>)(?!\\<\\|tool_response\\>).)+)?(?:\\<turn\\|\\>|\\<\\|tool_response\\>)?"
|
|
|
|
| 65 |
},
|
| 66 |
"soc_token": "<|channel>",
|
| 67 |
"sot_token": "<|turn>",
|
|
|
|
| 71 |
"think_token": "<|think|>",
|
| 72 |
"tokenizer_class": "GemmaTokenizer",
|
| 73 |
"unk_token": "<unk>"
|
| 74 |
+
}
|