魔搭notebook中,用户提示命令生成无意义字符串回复
from modelscope import AutoModelForCausalLM, AutoTokenizer, AutoConfig
from peft import PeftModel, PeftConfig
base_model_name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B"
config = AutoConfig.from_pretrained(
base_model_name,
trust_remote_code=True
)
config.parallel_style = "None"
print("Config is: ", str(config))
tokenizer = AutoTokenizer.from_pretrained(base_model_name)
base_model = AutoModelForCausalLM.from_config(
config,
trust_remote_code=True
)
model_dir = "/mnt/workspace/hf"
model = PeftModel.from_pretrained(
base_model,
model_dir
)
text = '''Generate an SVG based on the following text: a birth day cake
'''
inIds = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(
**inIds,
max_new_tokens=1024,
do_sample=True,
temperature=0.7,
top_p=0.9
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
==
response is printed as
Setting pad_token_id
to eos_token_id
:151643 for open-end generation.
Generate an SVG based on the following text: a birth day cake
适用 Beaver boldffabdfff todayedbcffc TaiabadˣfefQ ifbff Sharonfeeedabab/Linuxecd marks butbccfebdefaff branchesigy情况进行dbeca unresolved fivefbe他已经eba:async1 .ddf sweareaafcfefdeeadafaceacbaeccoorcbbfdfff stageedbbccec矿物aab,-feccfcce of_runtimeeeeeeffddeec Prestacade大幅提升fadffff there fullscreenUSTebafdf MerlinFffbcadffb OddsZWDcadbddfy.PNGbff hexdukaeabuttfbeecycleExposed][6 feasibility stagnad
以上程序什么不正确的设置,导致这个无意义的回复?
谢谢!