[GH-ISSUE #8] 示例3代码运行报错 #5

Closed
opened 2026-10-26 21:01:57 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @klmoretti on GitHub (Nov 3, 2023).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-Coder/issues/8

from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("./deepseek-coder-1.3b-instruct", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("./deepseek-coder-1.3b-instruct", trust_remote_code=True).cuda()
messages=[
... { 'role': 'user', 'content': "write a quick sort algorithm in python."}
... ]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'LlamaTokenizerFast' object has no attribute 'apply_chat_template'

Originally created by @klmoretti on GitHub (Nov 3, 2023). Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-Coder/issues/8 >>> from transformers import AutoTokenizer, AutoModelForCausalLM >>> tokenizer = AutoTokenizer.from_pretrained("./deepseek-coder-1.3b-instruct", trust_remote_code=True) >>> model = AutoModelForCausalLM.from_pretrained("./deepseek-coder-1.3b-instruct", trust_remote_code=True).cuda() >>> messages=[ ... { 'role': 'user', 'content': "write a quick sort algorithm in python."} ... ] >>> inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'LlamaTokenizerFast' object has no attribute 'apply_chat_template'
bsakaguchi 2026-10-26 21:01:57 +00:00
  • closed this issue
  • added the
    ENV
    label
Author
Owner

@DejianYang commented on GitHub (Nov 3, 2023):

please upgrade your transformers to latest version and try again.

<!-- gh-comment-id:1791852780 --> @DejianYang commented on GitHub (Nov 3, 2023): please upgrade your transformers to latest version and try again.
Author
Owner

@soloice commented on GitHub (Nov 5, 2023):

Added https://github.com/deepseek-ai/DeepSeek-Coder/blob/main/requirements.txt

<!-- gh-comment-id:1793626780 --> @soloice commented on GitHub (Nov 5, 2023): Added [https://github.com/deepseek-ai/DeepSeek-Coder/blob/main/requirements.txt](https://github.com/deepseek-ai/DeepSeek-Coder/blob/main/requirements.txt)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/DeepSeek-Coder#5
No description provided.