ariG23498 HF Staff commited on
Commit
816e4b4
·
verified ·
1 Parent(s): 915dd53

Upload google_gemma-3-4b-it_2.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. google_gemma-3-4b-it_2.txt +32 -1
google_gemma-3-4b-it_2.txt CHANGED
@@ -1 +1,32 @@
1
- Everything was good in google_gemma-3-4b-it_2.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ```CODE:
2
+ # Load model directly
3
+ from transformers import AutoProcessor, AutoModelForMultimodalLM
4
+
5
+ processor = AutoProcessor.from_pretrained("google/gemma-3-4b-it")
6
+ model = AutoModelForMultimodalLM.from_pretrained("google/gemma-3-4b-it")
7
+ messages = [
8
+ {
9
+ "role": "user",
10
+ "content": [
11
+ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"},
12
+ {"type": "text", "text": "What animal is on the candy?"}
13
+ ]
14
+ },
15
+ ]
16
+ inputs = processor.apply_chat_template(
17
+ messages,
18
+ add_generation_prompt=True,
19
+ tokenize=True,
20
+ return_dict=True,
21
+ return_tensors="pt",
22
+ ).to(model.device)
23
+
24
+ outputs = model.generate(**inputs, max_new_tokens=40)
25
+ print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
26
+ ```
27
+
28
+ ERROR:
29
+ Traceback (most recent call last):
30
+ File "/tmp/google_gemma-3-4b-it_2UF1l4j.py", line 24, in <module>
31
+ from transformers import AutoProcessor, AutoModelForMultimodalLM
32
+ ImportError: cannot import name 'AutoModelForMultimodalLM' from 'transformers' (/tmp/.cache/uv/environments-v2/6ac6bc408a1e2391/lib/python3.13/site-packages/transformers/__init__.py)