Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text generation webui加载qwen-7B-chat报错 #361

Closed
2 tasks done
TianYifan-Vincent opened this issue Sep 26, 2023 · 9 comments · Fixed by oobabooga/text-generation-webui#4121
Closed
2 tasks done

Comments

@TianYifan-Vincent
Copy link

是否已有关于该错误的issue或讨论? | Is there an existing issue / discussion for this?

  • 我已经搜索过已有的issues和讨论 | I have searched the existing issues / discussions

该问题是否在FAQ中有解答? | Is there an existing answer for this in FAQ?

  • 我已经搜索过FAQ | I have searched FAQ

当前行为 | Current Behavior

用text generation webui下载好 Qwen模型后加载,出现错误,请问是版本还是什么原因?有人遇到过吗?
File “/home/ubuntu/.cache/huggingface/modules/transformers_modules/Qwen_Qwen-7B-Chat/tokenization_qwen.py”, line 38, in _load_tiktoken_bpe

with open(tiktoken_bpe_file, "rb") as f:
TypeError: expected str, bytes or os.PathLike object, not NoneType

期望行为 | Expected Behavior

No response

复现方法 | Steps To Reproduce

No response

运行环境 | Environment

- OS:Ubuntu 20.04
- Python:3.10
- Transformers:4.33.2
- PyTorch:2.0.1
- CUDA:11.7

备注 | Anything else?

No response

@TianYifan-Vincent TianYifan-Vincent changed the title [BUG] <title>text generation webui加载qwen-7B-chat报错 text generation webui加载qwen-7B-chat报错 Sep 26, 2023
@rwmjhb
Copy link

rwmjhb commented Sep 27, 2023

File "C:\Users\admin/.cache\huggingface\modules\transformers_modules\Qwen_Qwen-7B\tokenization_qwen.py", line 38, in _load_tiktoken_bpe with open(tiktoken_bpe_file, "rb") as f: TypeError: expected str, bytes or os.PathLike object, not NoneType

win11系统也是报错,其他环境和上面一样。

@shadowinkstar
Copy link

shadowinkstar commented Sep 27, 2023

我在使用text-generation-webui下载14B模型的时候没有下载文件qwen.tiktoken,去千问在huggingface的网站[https://huggingface.co/Qwen/Qwen-14B-Chat]上面直接下载那个文件然后放到模型文件夹models/Qwen_Qwen-14B-Chat/下面然后再载入模型就可以解决了(7B应该也差不多?)

@TianYifan-Vincent
Copy link
Author

我在使用text-generation-webui下载14B模型的时候没有下载文件qwen.tiktoken,去千问在huggingface的网站[https://huggingface.co/Qwen/Qwen-14B-Chat]上面直接下载那个文件然后放到模型文件夹models/Qwen_Qwen-14B-Chat/下面然后再载入模型就可以解决了(7B应该也差不多?)

非常感谢!并没有注意到缺失了这个文件!已经解决该问题

@TianYifan-Vincent
Copy link
Author

我在使用text-generation-webui下载14B模型的时候没有下载文件qwen.tiktoken,去千问在huggingface的网站[https://huggingface.co/Qwen/Qwen-14B-Chat]上面直接下载那个文件然后放到模型文件夹models/Qwen_Qwen-14B-Chat/下面然后再载入模型就可以解决了(7B应该也差不多?)

请问您在使用14B模型进行推理时,是否遇到过推理不停止的情况,比如不能自然地结束对话内容。

@shadowinkstar
Copy link

我在使用text-generation-webui下载14B模型的时候没有下载文件qwen.tiktoken,去千问在huggingface的网站[https://huggingface.co/Qwen/Qwen-14B-Chat]上面直接下载那个文件然后放到模型文件夹models/Qwen_Qwen-14B-Chat/下面然后再载入模型就可以解决了(7B应该也差不多?)

请问您在使用14B模型进行推理时,是否遇到过推理不停止的情况,比如不能自然地结束对话内容。

是的,我在使用chat模式的时候,遇到过这个问题,例子如下:
image
image
采用的参数是tempreture=0.01, top_p=0.9,目前还没有进行更多的测试,我看有人说可以调整这两个参数来提升效果,或者说设置合适的终止符。

@shadowinkstar
Copy link

我初步搜索解决了这个模型生成无法解决的问题。主要方式是采用特殊的提示词模板与停止符,叙述如下:
#29 [https://github.com//issues/29] 这个issue涉及到停止符与提示词的相关设定,里面有人提到千问应该采用ChatML提示词模板如下(我加了冒号效果更好):

<|im_start|>system:
You are a helpful AI assistant.<|im_end|>
<|im_start|>user:
Please tell me a story<|im_end|>
<|im_start|>assistant:

可以看到上面的提示词里面有一些停止符,因此还需要把停止符设置到text-generation-webui,配置custom_stopping_strings为"<|im_end|>", "<|im_start|>", "<|endoftext|>",还需要设置skip_special_tokensFalse,更多原因与测试可以看相关issue #253 [https://github.com//issues/253],注意里面最后也提到text-generation-webui需要的停止符格式,直接传入列表会出错。
另外,我也测试了api的调用,需要在调用时额外设置上面说的两个参数。

@TianYifan-Vincent
Copy link
Author

<|im_end|>", "<|im_start|>", "<|endoftext|>"

很感谢您的帮助,我修改了您提到的两个参数在web的chat界面和api调用都正常推理了,但在default界面还是无法正常停止,您说的采用ChatML的提示词模板是直接在input输入这样吗,还是需要再哪里设置提示词模板?我不太熟悉
pic1
pic2
pic3

@shadowinkstar
Copy link

使用方式是正确的,使用方式就是把user后面的指令换成你想要使用的指令,然后截断的原理就是那些特殊符号,也可以适当修改模板,比如修改系统提示词system,或者全部换成中文的应该也可以。你这个示例输出结果虽然长但是内容都是合理的,基本都是在讲lily的故事,如果想要限制模型的输出长度,修改max_new_tokens参数就好。

@TianYifan-Vincent
Copy link
Author

使用方式是正确的,使用方式就是把user后面的指令换成你想要使用的指令,然后截断的原理就是那些特殊符号,也可以适当修改模板,比如修改系统提示词system,或者全部换成中文的应该也可以。你这个示例输出结果虽然长但是内容都是合理的,基本都是在讲lily的故事,如果想要限制模型的输出长度,修改max_new_tokens参数就好。

谢谢您的指导~~!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants