Bunny-v1.0-2B-zh 模型有时候用英文回答问题
thesby opened this issue · comments
Bunny-v1.0-2B-zh 模型有时候用英文回答问题
def chat(image_url, prompt):
image = read_image(image_url)
image_tensor = model.process_images([image], model.config).to(dtype=model.dtype)
text = f"你是一个非常好的人工智能助手,能够非常出色的和用户交谈. USER: <image>\n{prompt} ASSISTANT:"
text_chunks = [tokenizer(chunk).input_ids for chunk in text.split('<image>')]
input_ids = torch.tensor(text_chunks[0] + [-200] + text_chunks[1], dtype=torch.long).unsqueeze(0)
output_ids = model.generate(
input_ids,
images=image_tensor,
max_new_tokens=100,
use_cache=True)[0]
return tokenizer.decode(output_ids[input_ids.shape[1]:], skip_special_tokens=True).strip()
是不是 Qwen2 1.8B 的对话模版不一样?
Close the issue for now if there's no further discussions. Feel free to reopen it if there's any other questions.