Skip to content

Commit b89cc94

Browse files
authored
Fix broken VLM snippets on the hub. (#1462)
TL;DR: this is broken: ```diff # Use a pipeline as a high-level helper from transformers import pipeline import torch pipe = pipeline("image-text-to-text", model="google/gemma-3-4b-it", torch_dtype=torch.bfloat16) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] -pipe(messages) +pipe(text=messages) ``` there's some code duplication because `text-generation` models require ` pipe(messages)` which maps to `text_inputs` @gante is looking for a fix on transformers main but it might awhile till we actually get this in a version that works with colab. cc: @merveenoyan @sergiopaniego for vis too.
1 parent 4e04a5c commit b89cc94

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/tasks/src/model-libraries-snippets.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,10 +1164,11 @@ export const transformers = (model: ModelData): string[] => {
11641164
].join("\n"),
11651165
"]"
11661166
);
1167+
pipelineSnippet.push("pipe(text=messages)");
11671168
} else {
11681169
pipelineSnippet.push("messages = [", ' {"role": "user", "content": "Who are you?"},', "]");
1170+
pipelineSnippet.push("pipe(messages)");
11691171
}
1170-
pipelineSnippet.push("pipe(messages)");
11711172
}
11721173

11731174
return [pipelineSnippet.join("\n"), autoSnippet];

0 commit comments

Comments
 (0)