gemma-3n-tiny-random-dim4
51
4.0B
—
by
yujiepan
Image Model
OTHER
4B params
New
51 downloads
Early-stage
Edge AI:
Mobile
Laptop
Server
9GB+ RAM
Mobile
Laptop
Server
Quick Summary
AI model with specialized capabilities.
Device Compatibility
Mobile
4-6GB RAM
Laptop
16GB RAM
Server
GPU
Minimum Recommended
4GB+ RAM
Training Data Analysis
🟡 Average (4.3/10)
Researched training datasets used by gemma-3n-tiny-random-dim4 with quality assessment
Specialized For
general
science
multilingual
reasoning
Training Datasets (3)
common crawl
🔴 2.5/10
general
science
Key Strengths
- •Scale and Accessibility: At 9.5+ petabytes, Common Crawl provides unprecedented scale for training d...
- •Diversity: The dataset captures billions of web pages across multiple domains and content types, ena...
- •Comprehensive Coverage: Despite limitations, Common Crawl attempts to represent the broader web acro...
Considerations
- •Biased Coverage: The crawling process prioritizes frequently linked domains, making content from dig...
- •Large-Scale Problematic Content: Contains significant amounts of hate speech, pornography, violent c...
wikipedia
🟡 5/10
science
multilingual
Key Strengths
- •High-Quality Content: Wikipedia articles are subject to community review, fact-checking, and citatio...
- •Multilingual Coverage: Available in 300+ languages, enabling training of models that understand and ...
- •Structured Knowledge: Articles follow consistent formatting with clear sections, allowing models to ...
Considerations
- •Language Inequality: Low-resource language editions have significantly lower quality, fewer articles...
- •Biased Coverage: Reflects biases in contributor demographics; topics related to Western culture and ...
arxiv
🟡 5.5/10
science
reasoning
Key Strengths
- •Scientific Authority: Peer-reviewed content from established repository
- •Domain-Specific: Specialized vocabulary and concepts
- •Mathematical Content: Includes complex equations and notation
Considerations
- •Specialized: Primarily technical and mathematical content
- •English-Heavy: Predominantly English-language papers
Explore our comprehensive training dataset analysis
View All DatasetsCode Examples
Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Example usage:pythontransformers
import torch
from transformers import pipeline
model_id = "yujiepan/gemma-3n-tiny-random-dim4"
pipe = pipeline(
task="image-text-to-text",
model=model_id,
device=0,
torch_dtype=torch.bfloat16
)
# temporary patch for audio tower
from accelerate.hooks import ModelHook, add_hook_to_module
class EnsureDtype(ModelHook):
def pre_forward(self, module, *args, **kwargs):
args = list(args)
args[0] = args[0].to(module.dtype)
return super().pre_forward(module, *args, **kwargs)
add_hook_to_module(pipe.model.audio_tower, EnsureDtype())
messages = [
{
"role": "system",
"content": [
{"type": "text", "text": "You are a helpful assistant."}
]
},
{
"role": "user",
"content": [
{"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/pipeline-cat-chonk.jpeg"},
# audio is buggy for now: bf16 x fp32
{"type": "audio", "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-Audio/glass-breaking-151256.mp3"},
{"type": "text", "text": "Which image is cuter?"},
]
},
]
result = pipe(messages, min_new_tokens=512, max_new_tokens=512, do_sample=True)
print(result)Deploy This Model
Production-ready deployment in minutes
Together.ai
Instant API access to this model
Production-ready inference API. Start free, scale to millions.
Try Free APIReplicate
One-click model deployment
Run models in the cloud with simple API. No DevOps required.
Deploy NowDisclosure: We may earn a commission from these partners. This helps keep LLMYourWay free.