chatchat-space / Langchain-Chatchat

Langchain-Chatchat(原Langchain-ChatGLM)基于 Langchain 与 ChatGLM, Qwen 与 Llama 等语言模型的 RAG 与 Agent 应用 | Langchain-Chatchat (formerly langchain-ChatGLM), local knowledge based LLM (like ChatGLM, Qwen and Llama) RAG and Agent app with langchain
Apache License 2.0
31.68k stars 5.52k forks source link

[BUG] AttributeError: 'ChatGLMTokenizer' object has no attribute 'sp_tokenizer' #2181

Closed Ikaros-521 closed 10 months ago

Ikaros-521 commented 11 months ago

问题描述 / Problem Description chatglm3-6b-int4 AttributeError: 'ChatGLMTokenizer' object has no attribute 'sp_tokenizer' 复现问题的步骤 / Steps to Reproduce 配置 chatglm3-6b-int4模型后,运行就复现了

预期的结果 / Expected Result 正常加载运行

实际结果 / Actual Result

2023-11-26 19:48:12 | INFO | model_worker | Loading the model ['chatglm3-6b-int4'] on worker c69260c7 ...
2023-11-26 19:48:12 | ERROR | stderr | Process model_worker - chatglm3-6b-int4:
2023-11-26 19:48:12 | ERROR | stderr | Traceback (most recent call last):
2023-11-26 19:48:12 | ERROR | stderr |   File "D:\Langchain-Chatchat\Miniconda3\lib\multiprocessing\process.py", line 314, in _bootstrap
2023-11-26 19:48:12 | ERROR | stderr |     self.run()
2023-11-26 19:48:12 | ERROR | stderr |   File "D:\Langchain-Chatchat\Miniconda3\lib\multiprocessing\process.py", line 108, in run
2023-11-26 19:48:12 | ERROR | stderr |     self._target(*self._args, **self._kwargs)
2023-11-26 19:48:12 | ERROR | stderr |   File "D:\Langchain-Chatchat\startup.py", line 385, in run_model_worker
2023-11-26 19:48:12 | ERROR | stderr |     app = create_model_worker_app(log_level=log_level, **kwargs)
2023-11-26 19:48:12 | ERROR | stderr |   File "D:\Langchain-Chatchat\startup.py", line 213, in create_model_worker_app
2023-11-26 19:48:12 | ERROR | stderr |     worker = ModelWorker(
2023-11-26 19:48:12 | ERROR | stderr |   File "D:\Langchain-Chatchat\Miniconda3\lib\site-packages\fastchat\serve\model_worker.py", line 74, in __init__
2023-11-26 19:48:12 | ERROR | stderr |     self.model, self.tokenizer = load_model(
2023-11-26 19:48:12 | ERROR | stderr |   File "D:\Langchain-Chatchat\Miniconda3\lib\site-packages\fastchat\model\model_adapter.py", line 306, in load_model
2023-11-26 19:48:12 | ERROR | stderr |     model, tokenizer = adapter.load_model(model_path, kwargs)
2023-11-26 19:48:12 | ERROR | stderr |   File "D:\Langchain-Chatchat\Miniconda3\lib\site-packages\fastchat\model\model_adapter.py", line 730, in load_model
2023-11-26 19:48:12 | ERROR | stderr |     tokenizer = AutoTokenizer.from_pretrained(
2023-11-26 19:48:12 | ERROR | stderr |   File "D:\Langchain-Chatchat\Miniconda3\lib\site-packages\transformers\models\auto\tokenization_auto.py", line 755, in from_pretrained
2023-11-26 19:48:12 | ERROR | stderr |     return tokenizer_class.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
2023-11-26 19:48:12 | ERROR | stderr |   File "D:\Langchain-Chatchat\Miniconda3\lib\site-packages\transformers\tokenization_utils_base.py", line 2024, in from_pretrained
2023-11-26 19:48:12 | ERROR | stderr |     return cls._from_pretrained(
2023-11-26 19:48:12 | ERROR | stderr |   File "D:\Langchain-Chatchat\Miniconda3\lib\site-packages\transformers\tokenization_utils_base.py", line 2256, in _from_pretrained
2023-11-26 19:48:12 | ERROR | stderr |     tokenizer = cls(*init_inputs, **init_kwargs)
2023-11-26 19:48:12 | ERROR | stderr |   File "C:\Users\Administrator.DESKTOP-80QNCF2/.cache\huggingface\modules\transformers_modules\chatglm3-6b-int4\tokenization_chatglm.py", line 196, in __init__
2023-11-26 19:48:12 | ERROR | stderr |     super().__init__(
2023-11-26 19:48:12 | ERROR | stderr |   File "D:\Langchain-Chatchat\Miniconda3\lib\site-packages\transformers\tokenization_utils.py", line 367, in __init__
2023-11-26 19:48:12 | ERROR | stderr |     self._add_tokens(
2023-11-26 19:48:12 | ERROR | stderr |   File "D:\Langchain-Chatchat\Miniconda3\lib\site-packages\transformers\tokenization_utils.py", line 467, in _add_tokens
2023-11-26 19:48:12 | ERROR | stderr |     current_vocab = self.get_vocab().copy()
2023-11-26 19:48:12 | ERROR | stderr |   File "C:\Users\Administrator.DESKTOP-80QNCF2/.cache\huggingface\modules\transformers_modules\chatglm3-6b-int4\tokenization_chatglm.py", line 248, in get_vocab
2023-11-26 19:48:12 | ERROR | stderr |     vocab = {self._convert_id_to_token(i): i for i in range(self.vocab_size)}
2023-11-26 19:48:12 | ERROR | stderr |   File "C:\Users\Administrator.DESKTOP-80QNCF2/.cache\huggingface\modules\transformers_modules\chatglm3-6b-int4\tokenization_chatglm.py", line 244, in vocab_size
2023-11-26 19:48:12 | ERROR | stderr |     return self.sp_tokenizer.num_tokens
2023-11-26 19:48:12 | ERROR | stderr | AttributeError: 'ChatGLMTokenizer' object has no attribute 'sp_tokenizer'

环境信息 / Environment Information

附加信息 / Additional Information 添加与问题相关的任何其他信息 / Add any other information related to the issue.

D:\Langchain-Chatchat>Miniconda3\python.exe -m pip list
Package                       Version
----------------------------- ------------
accelerate                    0.23.0
aiofiles                      23.2.1
aiohttp                       3.8.5
aiolimiter                    1.1.0
aiosignal                     1.3.1
altair                        5.1.1
antlr4-python3-runtime        4.9.3
anyio                         3.7.1
async-timeout                 4.0.3
attrs                         23.1.0
bce-python-sdk                0.8.97
beautifulsoup4                4.12.2
blinker                       1.6.2
blis                          0.7.11
boltons                       23.0.0
Brotli                        1.1.0
brotlipy                      0.7.0
cachetools                    5.3.1
catalogue                     2.0.10
certifi                       2022.12.7
cffi                          1.15.1
chardet                       5.2.0
charset-normalizer            2.0.4
click                         8.1.7
colorama                      0.4.6
coloredlogs                   15.0.1
conda                         23.3.1
conda-content-trust           0.1.3
conda-package-handling        2.0.2
conda_package_streaming       0.7.0
confection                    0.1.3
contourpy                     1.1.1
cpm-kernels                   1.0.11
cryptography                  39.0.1
cycler                        0.11.0
cymem                         2.0.8
dashscope                     1.13.3
dataclasses                   0.6
dataclasses-json              0.5.14
duckduckgo-search             3.8.5
EbookLib                      0.18
effdet                        0.4.1
einops                        0.7.0
emoji                         2.8.0
et-xmlfile                    1.1.0
exceptiongroup                1.1.3
faiss-cpu                     1.7.4
fastapi                       0.104.1
filelock                      3.12.4
filetype                      1.2.0
flatbuffers                   23.5.26
fonttools                     4.42.1
frozenlist                    1.4.0
fschat                        0.2.32
fsspec                        2023.9.2
future                        0.18.3
gitdb                         4.0.10
GitPython                     3.1.37
greenlet                      2.0.2
h11                           0.14.0
h2                            4.1.0
hpack                         4.0.0
httpcore                      0.17.3
httpx                         0.24.1
huggingface-hub               0.17.3
humanfriendly                 10.0
hyperframe                    6.0.1
idna                          3.4
importlib-metadata            6.8.0
iniconfig                     2.0.0
iopath                        0.1.10
Jinja2                        3.1.2
joblib                        1.3.2
jsonpatch                     1.33
jsonpointer                   2.1
jsonschema                    4.19.1
jsonschema-specifications     2023.7.1
kiwisolver                    1.4.5
langchain                     0.0.340
langchain-experimental        0.0.42
langcodes                     3.3.0
langsmith                     0.0.66
layoutparser                  0.3.4
lxml                          4.9.3
Markdown                      3.4.4
markdown-it-py                3.0.0
markdown2                     2.4.10
markdownify                   0.11.6
MarkupSafe                    2.1.3
marshmallow                   3.20.1
matplotlib                    3.8.0
mdurl                         0.1.2
menuinst                      1.4.19
metaphor-python               0.1.21
mpmath                        1.3.0
msg-parser                    1.2.0
multidict                     6.0.4
murmurhash                    1.0.10
mypy-extensions               1.0.0
networkx                      3.1
nh3                           0.2.14
nltk                          3.8.1
numexpr                       2.8.7
numpy                         1.24.4
olefile                       0.46
omegaconf                     2.3.0
onnx                          1.14.1
onnxruntime                   1.16.0
openai                        0.28.1
opencv-python                 4.8.0.76
openpyxl                      3.1.2
packaging                     23.0
pandas                        2.0.3
pathlib                       1.0.1
pathy                         0.10.2
pdf2image                     1.16.3
pdfminer.six                  20221105
pdfplumber                    0.10.2
peft                          0.5.0
Pillow                        9.5.0
pip                           23.0.1
pluggy                        1.0.0
portalocker                   2.8.2
preshed                       3.0.9
prompt-toolkit                3.0.39
protobuf                      4.24.3
psutil                        5.9.5
pyarrow                       13.0.0
pyclipper                     1.3.0.post5
pycocotools                   2.0.7
pycosat                       0.6.4
pycparser                     2.21
pycryptodome                  3.19.0
pydantic                      1.10.13
pydeck                        0.8.1b0
Pygments                      2.16.1
PyJWT                         2.8.0
PyMuPDF                       1.22.5
pyOpenSSL                     23.0.0
pypandoc                      1.11
pyparsing                     3.1.1
pypdfium2                     4.20.0
pyreadline3                   3.4.1
PySocks                       1.7.1
pytesseract                   0.3.10
pytest                        7.4.2
python-dateutil               2.8.2
python-decouple               3.8
python-docx                   0.8.11
python-iso639                 2023.6.15
python-magic                  0.4.27
python-magic-bin              0.4.14
python-multipart              0.0.6
python-pptx                   0.6.21
pytz                          2023.3.post1
pywin32                       306
PyYAML                        6.0.1
qianfan                       0.1.1
rapidfuzz                     3.3.1
rapidocr-onnxruntime          1.3.7
referencing                   0.30.2
regex                         2023.8.8
requests                      2.28.1
rich                          13.5.3
rpds-py                       0.10.3
ruamel.yaml                   0.17.21
ruamel.yaml.clib              0.2.6
safetensors                   0.3.3
scikit-learn                  1.3.1
scipy                         1.11.3
sentence-transformers         2.2.2
sentencepiece                 0.1.99
setuptools                    65.6.3
shapely                       2.0.1
shortuuid                     1.0.11
simplejson                    3.19.1
six                           1.16.0
smart-open                    6.4.0
smmap                         5.0.1
sniffio                       1.3.0
socksio                       1.0.0
soupsieve                     2.5
spacy                         3.6.1
spacy-legacy                  3.0.12
spacy-loggers                 1.0.5
SQLAlchemy                    2.0.19
srsly                         2.4.8
starlette                     0.27.0
streamlit                     1.27.0
streamlit-aggrid              0.3.4.post3
streamlit-antd-components     0.2.1
streamlit-chatbox             1.1.11
streamlit-feedback            0.1.3
streamlit-option-menu         0.3.6
strsimpy                      0.2.1
svgwrite                      1.4.3
sympy                         1.12
tabulate                      0.9.0
tenacity                      8.2.3
thinc                         8.1.12
threadpoolctl                 3.2.0
tiktoken                      0.5.1
timm                          0.9.7
tokenizers                    0.14.1
toml                          0.10.2
tomli                         2.0.1
toolz                         0.12.0
torch                         2.1.0+cu121
torchaudio                    2.1.0+cu121
torchvision                   0.16.0+cu121
tornado                       6.3.3
tqdm                          4.65.0
transformers                  4.35.2
transformers-stream-generator 0.0.4
typer                         0.9.0
typing_extensions             4.8.0
typing-inspect                0.9.0
tzdata                        2023.3
tzlocal                       5.0.1
unstructured                  0.10.16
unstructured-inference        0.6.6
unstructured.pytesseract      0.3.12
urllib3                       1.26.15
uvicorn                       0.23.2
validators                    0.22.0
wasabi                        1.1.2
watchdog                      3.0.0
wavedrom                      2.0.3.post3
wcwidth                       0.2.6
websockets                    11.0.3
wheel                         0.38.4
win-inet-pton                 1.1.0
wincertstore                  0.2
xformers                      0.0.22.post7
xlrd                          2.0.1
XlsxWriter                    3.1.5
yarl                          1.9.2
zhipuai                       1.0.7
zipp                          3.17.0
zstandard                     0.19.0
Ikaros-521 commented 11 months ago

更换为 glm2-6b-int4 或者 glm3-6b,倒是没有报错,但是会卡死在,无法访问webui

 Fatal error in launcher: Unable to create process using '"E:\Langchain-Chatchat\Miniconda3\python.exe"  "D:\Langchain-Chatchat\Miniconda3\Scripts\streamlit.exe" run webui.py --server.address 127.0.0.1 --server.port 8501 --theme.base light --theme.primaryColor #165dff --theme.secondaryBackgroundColor #f5f5f5 --theme.textColor #000000': ???????????
 'port': 20002}
{'api_key': '',
 'device': 'auto',
 'host': '127.0.0.1',
 'infer_turbo': False,
 'online_api': True,
 'port': 21001,
 'provider': 'ChatGLMWorker',
 'version': 'chatglm_turbo',
 'worker_class': <class 'server.model_workers.zhipu.ChatGLMWorker'>}
{'api_base_url': 'https://api.openai.com/v1',
 'api_key': '',
 'device': 'auto',
 'host': '127.0.0.1',
 'infer_turbo': False,
 'model_name': 'gpt-3.5-turbo',
 'online_api': True,
 'openai_proxy': '',
 'port': 20002}
当前Embbedings模型: m3e-base @ cuda

服务端运行信息:
    OpenAI API Server: http://127.0.0.1:20000/v1
    Chatchat  API  Server: http://127.0.0.1:7861
    Chatchat WEBUI Server: http://127.0.0.1:8501
==============================Langchain-Chatchat Configuration==============================
Ikaros-521 commented 11 months ago

更换为 glm2-6b-int4 或者 glm3-6b,倒是没有报错,但是会卡死在,无法访问webui

 Fatal error in launcher: Unable to create process using '"E:\Langchain-Chatchat\Miniconda3\python.exe"  "D:\Langchain-Chatchat\Miniconda3\Scripts\streamlit.exe" run webui.py --server.address 127.0.0.1 --server.port 8501 --theme.base light --theme.primaryColor #165dff --theme.secondaryBackgroundColor #f5f5f5 --theme.textColor #000000': ???????????
 'port': 20002}
{'api_key': '',
 'device': 'auto',
 'host': '127.0.0.1',
 'infer_turbo': False,
 'online_api': True,
 'port': 21001,
 'provider': 'ChatGLMWorker',
 'version': 'chatglm_turbo',
 'worker_class': <class 'server.model_workers.zhipu.ChatGLMWorker'>}
{'api_base_url': 'https://api.openai.com/v1',
 'api_key': '',
 'device': 'auto',
 'host': '127.0.0.1',
 'infer_turbo': False,
 'model_name': 'gpt-3.5-turbo',
 'online_api': True,
 'openai_proxy': '',
 'port': 20002}
当前Embbedings模型: m3e-base @ cuda

服务端运行信息:
    OpenAI API Server: http://127.0.0.1:20000/v1
    Chatchat  API  Server: http://127.0.0.1:7861
    Chatchat WEBUI Server: http://127.0.0.1:8501
==============================Langchain-Chatchat Configuration==============================

更新了 streamlit 到 最新版 1.28.2 后运行成功

zRzRzRzRzRzRzR commented 10 months ago

记得按照现在dev分支中的依赖来装,应该可以解决这个问题

Ikaros-521 commented 10 months ago

记得按照现在dev分支中的依赖来装,应该可以解决这个问题

同套环境 不同电脑复现😌

koitoyuu3 commented 10 months ago

我一开始也是你这个问题,然后改了以下tansformers的版本就好了

koitoyuu3 commented 10 months ago

改成它需要的版本