Created
May 7, 2025 13:25
-
-
Save Vaibhavs10/b525c1ae4982c04fe0202c2f78ac2f03 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (model.pipeline_tag && LIBRARY_TASK_MAPPING.transformers?.includes(model.pipeline_tag)) { | |
const pipelineSnippet = ["# Use a pipeline as a high-level helper", "from transformers import pipeline", ""]; | |
if (model.config?.tokenizer_config?.chat_template) { | |
if (model.tags.includes("conversational") && model.tags.includes("image-text-to-text")) { | |
pipelineSnippet.push( | |
"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?"}', | |
" ]", | |
" },", | |
].join("\n"), | |
"]" | |
); | |
} else if (model.tags.includes("conversational")) { | |
pipelineSnippet.push("messages = [", ' {"role": "user", "content": "Who are you?"},', "]"); | |
} | |
} | |
pipelineSnippet.push(`pipe = pipeline("${model.pipeline_tag}", model="${model.id}"` + remote_code_snippet + ")"); | |
pipelineSnippet.push("pipe(messages)"); | |
return [pipelineSnippet.join("\n"), autoSnippet]; | |
} | |
return [autoSnippet]; |
Wauplin
commented
May 7, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment