Skip to content
Discussion options

You must be logged in to vote

尝试这么写

tokenizer = AutoTokenizer.from_pretrained(TOKENIZER_PATH, trust_remote_code=True,encode_special_tokens=True)
model = AutoModel.from_pretrained(MODEL_PATH, trust_remote_code=True, device_map="auto").eval()

messages = []
messages.append({"role": "user", "content": "你爱吃苹果吗"})
model_inputs = tokenizer.apply_chat_template(messages,
                                                 add_generation_prompt=True,
                                                 tokenize=True,
                                                 return_tensors="pt").to(next(model.parameters()).device)
model_input_tokens = tokenizer.convert_ids_to_tokens(model_inputs[0])

对应的huggingface代码会进行更新
正常运行你将会得到这个反馈

['[gMAS…

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@zRzRzRzRzRzRzR
Comment options

@ShaneTian
Comment options

@zRzRzRzRzRzRzR
Comment options

@zRzRzRzRzRzRzR
Comment options

Answer selected by ShaneTian
@ShaneTian
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants