[GH-ISSUE #28] finetune后的模型输出异常 #27

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

Originally created by @JustQJ on GitHub (Feb 29, 2024).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-MoE/issues/28

按照提供的finetune.py脚本在alpaca数据上微调后,使用下面的代码测试模型,输出有多余的 <|EOT|>符号,请问怎么纠正去掉这些符号,谢谢。
测试代码:

model.eval()
    tokenizer = AutoTokenizer.from_pretrained(tokenizer_path)
    messages = [
        {"role": "user", "content": "How to learn English?"},
    ]
    input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")

    
    outputs = model.generate(input_tensor.to(model.device), max_new_tokens=max_new_tokens)
    result = tokenizer.decode(outputs[0][input_tensor.shape[1]:], skip_special_tokens=True)
    print(result)

模型输出:

1. Reading: Reading is the first step in learning English. It helps to develop vocabulary, grammar, and pronunciation skills. Choose a picture book or a good friend to read on.

2. Writing: Writing is a great way to practice grammar and sentence structure. Write short stories or practice writing on a computer or journal.

3. Listening and Speaking: Listening to English and speaking in front of an English audience can help to improve pronunciation and listening skills.

4. Reading books and games: Reading books and games with English can help to develop vocabulary, reading style, and comprehension skills. Choose books and games that have interactive elements and that challenge you.

5. Speaking with an English tutor or tutor in a classroom: Having a trained English tutor or tutor in a classroom can provide you with real-life practice and help you improve grammar and vocabulary skills.

6. Watching movies and TV shows: Watching movies and TV shows with subtitles or in international English can help to improve your listening skills and vocabulary. Choose movies and shows that have subtitles or that feature English characters.

7. Playing with a native speaker: Playing with a native speaker of the language can help to improve pronunciation and vocabulary skills. Choose a friend to play with and practice in a group.


8. Speaking with a real-life English person: Speaking with a real-life English person can help to improve grammar, vocabulary, and listening skills. Choose a friend to practice with a trained English tutor or tutor.
<|EOT|>OT|>2. Playing with all of these methods above can help to improve your English skills.
<||EOT|>||
<|EOT|>|
<|EOT|>|
<|EOT|>
<|EOT|>
<|EOT|>
<|EOT|>
<|EOT|>
<EOT>
<|EOT|>
<|EOT>
<|EOT>
<|EOT>
<|EOT>
<EOT>
<EOT>
<|EOT>
<EOT>
<EOT>
<|EOT>
<EOT>
<EOT>
<|EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOTOT>
<EOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<<EOTOT>
<EOT>
<EOT>
<EOT>EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOTEOT>
<EOTOTEOT>
<EOTOTEOT>
<EOTOTEOT>
<EOTOTOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOT>
<EOTOT>
<EOT>
<EOTOTOT
<EOTOTOT
Originally created by @JustQJ on GitHub (Feb 29, 2024). Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-MoE/issues/28 按照提供的finetune.py脚本在[alpaca](https://huggingface.co/datasets/yahma/alpaca-cleaned)数据上微调后,使用下面的代码测试模型,输出有多余的` <|EOT|>`符号,请问怎么纠正去掉这些符号,谢谢。 测试代码: ```a model.eval() tokenizer = AutoTokenizer.from_pretrained(tokenizer_path) messages = [ {"role": "user", "content": "How to learn English?"}, ] input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt") outputs = model.generate(input_tensor.to(model.device), max_new_tokens=max_new_tokens) result = tokenizer.decode(outputs[0][input_tensor.shape[1]:], skip_special_tokens=True) print(result) ``` 模型输出: ``` 1. Reading: Reading is the first step in learning English. It helps to develop vocabulary, grammar, and pronunciation skills. Choose a picture book or a good friend to read on. 2. Writing: Writing is a great way to practice grammar and sentence structure. Write short stories or practice writing on a computer or journal. 3. Listening and Speaking: Listening to English and speaking in front of an English audience can help to improve pronunciation and listening skills. 4. Reading books and games: Reading books and games with English can help to develop vocabulary, reading style, and comprehension skills. Choose books and games that have interactive elements and that challenge you. 5. Speaking with an English tutor or tutor in a classroom: Having a trained English tutor or tutor in a classroom can provide you with real-life practice and help you improve grammar and vocabulary skills. 6. Watching movies and TV shows: Watching movies and TV shows with subtitles or in international English can help to improve your listening skills and vocabulary. Choose movies and shows that have subtitles or that feature English characters. 7. Playing with a native speaker: Playing with a native speaker of the language can help to improve pronunciation and vocabulary skills. Choose a friend to play with and practice in a group. 8. Speaking with a real-life English person: Speaking with a real-life English person can help to improve grammar, vocabulary, and listening skills. Choose a friend to practice with a trained English tutor or tutor. <|EOT|>OT|>2. Playing with all of these methods above can help to improve your English skills. <||EOT|>|| <|EOT|>| <|EOT|>| <|EOT|> <|EOT|> <|EOT|> <|EOT|> <|EOT|> <EOT> <|EOT|> <|EOT> <|EOT> <|EOT> <|EOT> <EOT> <EOT> <|EOT> <EOT> <EOT> <|EOT> <EOT> <EOT> <|EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOTOT> <EOT> <EOT> <EOT> <EOTOT> <EOT> <<EOTOT> <EOT> <EOT> <EOT>EOT> <EOTOT> <EOT> <EOT> <EOTOTEOT> <EOTOTEOT> <EOTOTEOT> <EOTOTEOT> <EOTOTOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOT> <EOTOT> <EOT> <EOTOTOT <EOTOTOT ```
Author
Owner

@zwd003 commented on GitHub (Mar 1, 2024):

你好,可以将换成eos这个special_token

<!-- gh-comment-id:1972362082 --> @zwd003 commented on GitHub (Mar 1, 2024): 你好,可以将<EOT>换成eos这个special_token
Author
Owner

@JustQJ commented on GitHub (Mar 1, 2024):

你好,可以将换成eos这个special_token

不好意思,没有理解什么意思,请问将什么换成eos,是指在生成时将tokenizer中的eos_token换成<|EOT|>,还是在训练时将<|EOT|>换成tokenizer中的eos_token

<!-- gh-comment-id:1972551294 --> @JustQJ commented on GitHub (Mar 1, 2024): > 你好,可以将换成eos这个special_token 不好意思,没有理解什么意思,请问将什么换成eos,是指在生成时将tokenizer中的eos_token换成`<|EOT|>`,还是在训练时将`<|EOT|>`换成tokenizer中的eos_token
Author
Owner

@zwd003 commented on GitHub (Mar 4, 2024):

换成tokenizer中的eos_token

<!-- gh-comment-id:1976040636 --> @zwd003 commented on GitHub (Mar 4, 2024): 换成tokenizer中的eos_token
Author
Owner

@JustQJ commented on GitHub (Mar 4, 2024):

换成tokenizer中的eos_token

好的,谢谢

<!-- gh-comment-id:1976350435 --> @JustQJ commented on GitHub (Mar 4, 2024): > 换成tokenizer中的eos_token 好的,谢谢
Sign in to join this conversation.
No labels
pull-request
WIP
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-MoE#27
No description provided.