Upload google_translategemma-12b-it_2.txt with huggingface_hub
Browse files
google_translategemma-12b-it_2.txt
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```CODE:
|
| 2 |
+
# Load model directly
|
| 3 |
+
from transformers import AutoProcessor, AutoModelForImageTextToText
|
| 4 |
+
|
| 5 |
+
processor = AutoProcessor.from_pretrained("google/translategemma-12b-it")
|
| 6 |
+
model = AutoModelForImageTextToText.from_pretrained("google/translategemma-12b-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_translategemma-12b-it_2DMIrNm.py", line 37, in <module>
|
| 31 |
+
inputs = processor.apply_chat_template(
|
| 32 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
|
| 33 |
+
messages,
|
| 34 |
+
^^^^^^^^^
|
| 35 |
+
...<3 lines>...
|
| 36 |
+
return_tensors="pt",
|
| 37 |
+
^^^^^^^^^^^^^^^^^^^^
|
| 38 |
+
).to(model.device)
|
| 39 |
+
^
|
| 40 |
+
File "/tmp/.cache/uv/environments-v2/d3078c48feea4d2f/lib/python3.13/site-packages/transformers/processing_utils.py", line 1792, in apply_chat_template
|
| 41 |
+
prompt, generation_indices = render_jinja_template(
|
| 42 |
+
~~~~~~~~~~~~~~~~~~~~~^
|
| 43 |
+
conversations=conversations,
|
| 44 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 45 |
+
...<2 lines>...
|
| 46 |
+
**special_tokens_map, # tokenizer special tokens are used by some templates
|
| 47 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 48 |
+
)
|
| 49 |
+
^
|
| 50 |
+
File "/tmp/.cache/uv/environments-v2/d3078c48feea4d2f/lib/python3.13/site-packages/transformers/utils/chat_template_utils.py", line 537, in render_jinja_template
|
| 51 |
+
rendered_chat = compiled_template.render(
|
| 52 |
+
messages=chat,
|
| 53 |
+
...<3 lines>...
|
| 54 |
+
**kwargs,
|
| 55 |
+
)
|
| 56 |
+
File "/tmp/.cache/uv/environments-v2/d3078c48feea4d2f/lib/python3.13/site-packages/jinja2/environment.py", line 1295, in render
|
| 57 |
+
self.environment.handle_exception()
|
| 58 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
|
| 59 |
+
File "/tmp/.cache/uv/environments-v2/d3078c48feea4d2f/lib/python3.13/site-packages/jinja2/environment.py", line 942, in handle_exception
|
| 60 |
+
raise rewrite_traceback_stack(source=source)
|
| 61 |
+
File "<template>", line 601, in top-level template code
|
| 62 |
+
File "/tmp/.cache/uv/environments-v2/d3078c48feea4d2f/lib/python3.13/site-packages/jinja2/sandbox.py", line 401, in call
|
| 63 |
+
return __context.call(__obj, *args, **kwargs)
|
| 64 |
+
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
|
| 65 |
+
File "/tmp/.cache/uv/environments-v2/d3078c48feea4d2f/lib/python3.13/site-packages/transformers/utils/chat_template_utils.py", line 445, in raise_exception
|
| 66 |
+
raise jinja2.exceptions.TemplateError(message)
|
| 67 |
+
jinja2.exceptions.TemplateError: User role must provide `content` as an iterable with exactly one item. That item must be a `mapping(type:'text' | 'image', source_lang_code:string, target_lang_code:string, text:string | none, image:string | none)`.
|