How to prompt text Q&A using llama3.2

Dears,
I needed to change this llama3.2 image reasoning example to ask question “what is the capital of USA”
below is the image example that I got from HG model card

messages = [
{“role”: “user”, “content”: [
{“type”: “image”},
{“type”: “text”, “text”: "Describe this image: "}
]}
]
input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
inputs = processor(
image,
input_text,
add_special_tokens=False,
return_tensors=“pt”
).to(model.device)

output = model.generate(**inputs, max_new_tokens=330)
print(processor.decode(output[0]))

i sloved it using this code
messages = [
{“role”: “user”, “content”: [
{“type”: “image”},
{“type”: “text”, “text”: "what is written in the image: "}
]}
]
input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
inputs = processor(
image,
input_text,
add_special_tokens=False,
return_tensors=“pt”
).to(model.device)

output = model.generate(**inputs, max_new_tokens=250)
#print(processor.decode(output[0]))

Decode the model’s output to get the text response

decoded_output = processor.decode(output[0], skip_special_tokens=True)

Post-process the decoded output to extract the answer (removing headers and eot tokens)

This assumes that the model’s answer follows a consistent pattern

answer = decoded_output.split(“assistant”)[-1].strip().replace(“<|eot_id|>”, “”).strip()

Print the clean answer

print(answer)