[Doc] Update mllama example based on official doc (#11567)

Signed-off-by: Chen Zhang <zhangch99@outlook.com>
This commit is contained in:
Chen Zhang 2024-12-28 08:31:10 +08:00 committed by GitHub
parent ac79799403
commit a60731247f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -308,7 +308,20 @@ def run_mllama(question: str, modality: str):
disable_mm_preprocessor_cache=args.disable_mm_preprocessor_cache,
)
prompt = f"<|image|><|begin_of_text|>{question}"
tokenizer = AutoTokenizer.from_pretrained(model_name)
messages = [{
"role":
"user",
"content": [{
"type": "image"
}, {
"type": "text",
"text": f"{question}"
}]
}]
prompt = tokenizer.apply_chat_template(messages,
add_generation_prompt=True,
tokenize=False)
stop_token_ids = None
return llm, prompt, stop_token_ids