From 5281ff529a9a25223ff77ae11ea342c38c5ab8c5 Mon Sep 17 00:00:00 2001 From: Chen Zhang Date: Sat, 28 Dec 2024 08:31:10 +0800 Subject: [PATCH] [Doc] Update mllama example based on official doc (#11567) Signed-off-by: Chen Zhang --- examples/offline_inference_vision_language.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/offline_inference_vision_language.py b/examples/offline_inference_vision_language.py index d5a71862656e7..77af914a6ef02 100644 --- a/examples/offline_inference_vision_language.py +++ b/examples/offline_inference_vision_language.py @@ -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