Instructions to use tiny-random/gemma-4e with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/gemma-4e with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="tiny-random/gemma-4e") 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("tiny-random/gemma-4e") model = AutoModelForImageTextToText.from_pretrained("tiny-random/gemma-4e") 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 tiny-random/gemma-4e with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/gemma-4e" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/gemma-4e", "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/tiny-random/gemma-4e
- SGLang
How to use tiny-random/gemma-4e 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 "tiny-random/gemma-4e" \ --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": "tiny-random/gemma-4e", "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 "tiny-random/gemma-4e" \ --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": "tiny-random/gemma-4e", "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 tiny-random/gemma-4e with Docker Model Runner:
docker model run hf.co/tiny-random/gemma-4e
Upload folder using huggingface_hub
Browse files- .meta.json +1 -1
- README.md +5 -5
- model.safetensors +1 -1
.meta.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"torch": "2.
|
| 3 |
"transformers": "5.9.0"
|
| 4 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"torch": "2.10.0+cu130",
|
| 3 |
"transformers": "5.9.0"
|
| 4 |
}
|
README.md
CHANGED
|
@@ -28,7 +28,7 @@ messages = [
|
|
| 28 |
"content": [
|
| 29 |
{
|
| 30 |
"type": "audio",
|
| 31 |
-
"audio": "https://
|
| 32 |
},
|
| 33 |
{"type": "text", "text": "Transcribe the following speech segment."},
|
| 34 |
],
|
|
@@ -42,7 +42,7 @@ messages = [
|
|
| 42 |
"content": [
|
| 43 |
{
|
| 44 |
"type": "image",
|
| 45 |
-
"url": "https://raw.githubusercontent.com/google-gemma/cookbook/
|
| 46 |
},
|
| 47 |
{"type": "text", "text": "What is shown in this image?"},
|
| 48 |
],
|
|
@@ -345,12 +345,12 @@ Gemma4ForConditionalGeneration(
|
|
| 345 |
(subsample_conv_projection): Gemma4AudioSubSampleConvProjection(
|
| 346 |
(layer0): Gemma4AudioSubSampleConvProjectionLayer(
|
| 347 |
(conv): Conv2d(1, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
|
| 348 |
-
(norm): LayerNorm((128,), eps=1e-06, elementwise_affine=True
|
| 349 |
(act): ReLU()
|
| 350 |
)
|
| 351 |
(layer1): Gemma4AudioSubSampleConvProjectionLayer(
|
| 352 |
(conv): Conv2d(128, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
|
| 353 |
-
(norm): LayerNorm((32,), eps=1e-06, elementwise_affine=True
|
| 354 |
(act): ReLU()
|
| 355 |
)
|
| 356 |
(input_proj_linear): Linear(in_features=1024, out_features=64, bias=False)
|
|
@@ -431,5 +431,5 @@ Gemma4ForConditionalGeneration(
|
|
| 431 |
|
| 432 |
### Test environment:
|
| 433 |
|
| 434 |
-
- torch: 2.
|
| 435 |
- transformers: 5.9.0
|
|
|
|
| 28 |
"content": [
|
| 29 |
{
|
| 30 |
"type": "audio",
|
| 31 |
+
"audio": "https://github.com/google-gemma/cookbook/raw/refs/heads/main/apps/sample-data/journal1.wav",
|
| 32 |
},
|
| 33 |
{"type": "text", "text": "Transcribe the following speech segment."},
|
| 34 |
],
|
|
|
|
| 42 |
"content": [
|
| 43 |
{
|
| 44 |
"type": "image",
|
| 45 |
+
"url": "https://raw.githubusercontent.com/google-gemma/cookbook/4a352192744f73fba5b80aeea3a8ba9b543edd29/apps/sample-data/surprise.png",
|
| 46 |
},
|
| 47 |
{"type": "text", "text": "What is shown in this image?"},
|
| 48 |
],
|
|
|
|
| 345 |
(subsample_conv_projection): Gemma4AudioSubSampleConvProjection(
|
| 346 |
(layer0): Gemma4AudioSubSampleConvProjectionLayer(
|
| 347 |
(conv): Conv2d(1, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
|
| 348 |
+
(norm): LayerNorm((128,), eps=1e-06, elementwise_affine=True)
|
| 349 |
(act): ReLU()
|
| 350 |
)
|
| 351 |
(layer1): Gemma4AudioSubSampleConvProjectionLayer(
|
| 352 |
(conv): Conv2d(128, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
|
| 353 |
+
(norm): LayerNorm((32,), eps=1e-06, elementwise_affine=True)
|
| 354 |
(act): ReLU()
|
| 355 |
)
|
| 356 |
(input_proj_linear): Linear(in_features=1024, out_features=64, bias=False)
|
|
|
|
| 431 |
|
| 432 |
### Test environment:
|
| 433 |
|
| 434 |
+
- torch: 2.10.0+cu130
|
| 435 |
- transformers: 5.9.0
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 9470740
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:032cdee368a3cf233b3ec293cff59bdbcf7d39a836d66b34f44337151da85fe0
|
| 3 |
size 9470740
|