Files
engine/scripts/testgen_vision.py
Eric BuehlerandGitHub aa93bdac25 Support the Phi 3.5 V model (#710)
* Update image_seq_len

* Update the examples

* Format
2024-08-23 10:43:14 -04:00

47 lines
1.3 KiB
Python

import transformers
processor = transformers.AutoProcessor.from_pretrained(
"microsoft/Phi-3.5-vision-instruct", trust_remote_code=True
)
res = processor.tokenizer.apply_chat_template(
[
{
"role": "system",
"content": [{"type": "text", "text": "You are a helpful assistant"}],
},
{
"role": "user",
"content": [
{"type": "image"},
{
"type": "text",
"text": "Hello, please describe the above.",
},
],
},
{"role": "assistant", "content": [{"type": "text", "text": "Hi there"}]},
{
"role": "user",
"content": [
{"type": "image"},
{"type": "text", "text": "This is me, who are you"},
],
},
{
"role": "assistant",
"content": [{"type": "text", "text": " I am an assistant "}],
},
{
"role": "user",
"content": [
{"type": "image"},
{"type": "text", "text": "Another question, what is this?"},
],
},
],
add_generation_prompt=True,
tokenize=False,
)
print(res.replace("\n", "\\n"))