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.44k stars 5.48k forks source link

python startup.py -a后出现问题 #3135

Closed cstkn closed 7 months ago

cstkn commented 7 months ago

手动下载的模型不知道要放在哪里能被正常检测,并且出现以下报错 2024-03-01 18:48:26,514 - startup.py[line:655] - INFO: 正在启动服务: 2024-03-01 18:48:26,514 - startup.py[line:656] - INFO: 如需查看 llm_api 日志,请前往 D:\wujiaping\chatglm\langchain-chatchat\logs D:\wujiaping\chatglm.venv\Lib\site-packages\langchain_core_api\deprecation.py:117: LangChainDeprecationWarning: 模型启动功能将于 Langchain-Chatchat 0.3.x重写,支持更多模式和加速启动,0.2.x中相关功能将废弃 warn_deprecated( 2024-03-01 18:48:30 | INFO | model_worker | Register to controller 2024-03-01 18:48:30 | ERROR | stderr | INFO: Started server process [5192] 2024-03-01 18:48:30 | ERROR | stderr | INFO: Waiting for application startup. 2024-03-01 18:48:30 | ERROR | stderr | INFO: Application startup complete. 2024-03-01 18:48:30 | ERROR | stderr | INFO: Uvicorn running on http://127.0.0.1:20000 (Press CTRL+C to quit) 2024-03-01 18:48:31 | INFO | model_worker | Loading the model ['chatglm3-6b'] on worker 9f519a57 ... 2024-03-01 18:48:38 | INFO | stdout | INFO: 127.0.0.1:53553 - "GET / HTTP/1.1" 404 Not Found

2024-03-01 18:48:56 | INFO | stdout | INFO: 127.0.0.1:53554 - "GET / HTTP/1.1" 404 Not Found 2024-03-01 18:49:11 | WARNING | transformers_modules.THUDM.chatglm3-6b.9addbe01105ca1939dd60a0e5866a1812be9daea.tokenization_chatglm | Setting eos_token is not supported, use the default one. 2024-03-01 18:49:11 | WARNING | transformers_modules.THUDM.chatglm3-6b.9addbe01105ca1939dd60a0e5866a1812be9daea.tokenization_chatglm | Setting pad_token is not supported, use the default one. 2024-03-01 18:49:11 | WARNING | transformers_modules.THUDM.chatglm3-6b.9addbe01105ca1939dd60a0e5866a1812be9daea.tokenization_chatglm | Setting unk_token is not supported, use the default one. 2024-03-01 18:49:51 | ERROR | stderr | Process model_worker - chatglm3-6b: 2024-03-01 18:49:51 | ERROR | stderr | Traceback (most recent call last): 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\urllib3\connection.py", line 198, in _new_conn 2024-03-01 18:49:51 | ERROR | stderr | sock = connection.create_connection( 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\urllib3\util\connection.py", line 85, in create_connection 2024-03-01 18:49:51 | ERROR | stderr | raise err 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\urllib3\util\connection.py", line 73, in create_connection 2024-03-01 18:49:51 | ERROR | stderr | sock.connect(sa) 2024-03-01 18:49:51 | ERROR | stderr | TimeoutError: timed out 2024-03-01 18:49:51 | ERROR | stderr | 2024-03-01 18:49:51 | ERROR | stderr | The above exception was the direct cause of the following exception: 2024-03-01 18:49:51 | ERROR | stderr | 2024-03-01 18:49:51 | ERROR | stderr | Traceback (most recent call last): 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\urllib3\connectionpool.py", line 793, in urlopen 2024-03-01 18:49:51 | ERROR | stderr | response = self._make_request( 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\urllib3\connectionpool.py", line 491, in _make_request 2024-03-01 18:49:51 | ERROR | stderr | raise new_e 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\urllib3\connectionpool.py", line 467, in _make_request 2024-03-01 18:49:51 | ERROR | stderr | self._validate_conn(conn) 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\urllib3\connectionpool.py", line 1099, in _validate_conn 2024-03-01 18:49:51 | ERROR | stderr | conn.connect() 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\urllib3\connection.py", line 616, in connect 2024-03-01 18:49:51 | ERROR | stderr | self.sock = sock = self._new_conn() 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\urllib3\connection.py", line 207, in _new_conn 2024-03-01 18:49:51 | ERROR | stderr | raise ConnectTimeoutError( 2024-03-01 18:49:51 | ERROR | stderr | urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x0000026FEF6F9990>, 'Connection to huggingface.co timed out. (connect timeout=10)') 2024-03-01 18:49:51 | ERROR | stderr | 2024-03-01 18:49:51 | ERROR | stderr | The above exception was the direct cause of the following exception: 2024-03-01 18:49:51 | ERROR | stderr | 2024-03-01 18:49:51 | ERROR | stderr | Traceback (most recent call last): 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\requests\adapters.py", line 486, in send 2024-03-01 18:49:51 | ERROR | stderr | resp = conn.urlopen( 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\urllib3\connectionpool.py", line 847, in urlopen 2024-03-01 18:49:51 | ERROR | stderr | retries = retries.increment( 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\urllib3\util\retry.py", line 515, in increment 2024-03-01 18:49:51 | ERROR | stderr | raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /THUDM/chatglm3-6b/resolve/main/config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000026FEF6F9990>, 'Connection to huggingface.co timed out. (connect timeout=10)')) 2024-03-01 18:49:51 | ERROR | stderr | 2024-03-01 18:49:51 | ERROR | stderr | During handling of the above exception, another exception occurred: 2024-03-01 18:49:51 | ERROR | stderr | 2024-03-01 18:49:51 | ERROR | stderr | Traceback (most recent call last): 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\huggingface_hub\file_download.py", line 1261, in hf_hub_download 2024-03-01 18:49:51 | ERROR | stderr | metadata = get_hf_file_metadata( 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\huggingface_hub\utils_validators.py", line 118, in _inner_fn 2024-03-01 18:49:51 | ERROR | stderr | return fn(args, kwargs) 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\huggingface_hub\file_download.py", line 1667, in get_hf_file_metadata 2024-03-01 18:49:51 | ERROR | stderr | r = _request_wrapper( 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\huggingface_hub\file_download.py", line 385, in _request_wrapper 2024-03-01 18:49:51 | ERROR | stderr | response = _request_wrapper( 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\huggingface_hub\file_download.py", line 408, in _request_wrapper 2024-03-01 18:49:51 | ERROR | stderr | response = get_session().request(method=method, url=url, params) 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\requests\sessions.py", line 589, in request 2024-03-01 18:49:51 | ERROR | stderr | resp = self.send(prep, send_kwargs) 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\requests\sessions.py", line 703, in send 2024-03-01 18:49:51 | ERROR | stderr | r = adapter.send(request, kwargs) 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\huggingface_hub\utils_http.py", line 67, in send 2024-03-01 18:49:51 | ERROR | stderr | return super().send(request, args, kwargs) 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\requests\adapters.py", line 507, in send 2024-03-01 18:49:51 | ERROR | stderr | raise ConnectTimeout(e, request=request) 2024-03-01 18:49:51 | ERROR | stderr | requests.exceptions.ConnectTimeout: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /THUDM/chatglm3-6b/resolv e/main/config.json (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000026FEF6F9990>, 'Connection to huggingface.co timed out. (connect timeout=10)'))"), '(Request ID: 799b0b6a-cc76-4dc9-81a7-4b583cd35cc4)') 2024-03-01 18:49:51 | ERROR | stderr | 2024-03-01 18:49:51 | ERROR | stderr | The above exception was the direct cause of the following exception: 2024-03-01 18:49:51 | ERROR | stderr | 2024-03-01 18:49:51 | ERROR | stderr | Traceback (most recent call last): 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\transformers\utils\hub.py", line 385, in cached_file 2024-03-01 18:49:51 | ERROR | stderr | resolved_file = hf_hub_download( 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\huggingface_hub\utils_validators.py", line 118, in _inner_fn 2024-03-01 18:49:51 | ERROR | stderr | return fn(*args, *kwargs) 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\huggingface_hub\file_download.py", line 1406, in hf_hub_download 2024-03-01 18:49:51 | ERROR | stderr | raise LocalEntryNotFoundError( 2024-03-01 18:49:51 | ERROR | stderr | huggingface_hub.utils._errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on. 2024-03-01 18:49:51 | ERROR | stderr | 2024-03-01 18:49:51 | ERROR | stderr | The above exception was the direct cause of the following exception: 2024-03-01 18:49:51 | ERROR | stderr | 2024-03-01 18:49:51 | ERROR | stderr | Traceback (most recent call last): 2024-03-01 18:49:51 | ERROR | stderr | File "C:\Users\lycor\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\process.py", line 314, in _bootstrap 2024-03-01 18:49:51 | ERROR | stderr | self.run() 2024-03-01 18:49:51 | ERROR | stderr | File "C:\Users\lycor\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\process.py", line 108, in run 2024-03-01 18:49:51 | ERROR | stderr | self._target(self._args, self._kwargs) 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm\langchain-chatchat\startup.py", line 389, in run_model_worker 2024-03-01 18:49:51 | ERROR | stderr | app = create_model_worker_app(log_level=log_level, kwargs) 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm\langchain-chatchat\startup.py", line 217, in create_model_worker_app 2024-03-01 18:49:51 | ERROR | stderr | worker = ModelWorker( 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\fastchat\serve\model_worker.py", line 77, in init 2024-03-01 18:49:51 | ERROR | stderr | self.model, self.tokenizer = load_model( 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\fastchat\model\model_adapter.py", line 348, in load_model 2024-03-01 18:49:51 | ERROR | stderr | model, tokenizer = adapter.load_model(model_path, kwargs) 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\fastchat\model\model_adapter.py", line 826, in load_model 2024-03-01 18:49:51 | ERROR | stderr | model = AutoModel.from_pretrained( 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\transformers\models\auto\auto_factory.py", line 526, in from_pretrained 2024-03-01 18:49:51 | ERROR | stderr | config, kwargs = AutoConfig.from_pretrained( 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\transformers\models\auto\configuration_auto.py", line 1100, in from_pretrained 2024-03-01 18:49:51 | ERROR | stderr | config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, kwargs) 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\transformers\configuration_utils.py", line 634, in get_config_dict 2024-03-01 18:49:51 | ERROR | stderr | config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs) 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\transformers\configuration_utils.py", line 689, in _get_config_dict 2024-03-01 18:49:51 | ERROR | stderr | resolved_config_file = cached_file( 2024-03-01 18:49:51 | ERROR | stderr | ^^^^^^^^^^^^ 2024-03-01 18:49:51 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\transformers\utils\hub.py", line 425, in cached_file 2024-03-01 18:49:51 | ERROR | stderr | raise EnvironmentError( 2024-03-01 18:49:51 | ERROR | stderr | OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like THUDM/chatglm3-6b is not the path to a directory containing a file named config.json. 2024-03-01 18:49:51 | ERROR | stderr | Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

dosubot[bot] commented 7 months ago

Hey there, @cstkn! Good to see you back. Running into some new challenges, I see? Let’s dive into it.

Based on the issues you've encountered, it seems like the application is having trouble locating the model files in your local environment and is attempting to download them from the internet, which is causing the connection timeout errors. Here are some steps you can take to resolve these issues:

  1. Modify the tokenizer_config.json file: As suggested in the issue #3074, you can modify the tokenizer_config.json file for the chatglm3-6b model. Change the auto_map entry from:
  "auto_map": {
    "AutoTokenizer": [
      "THUDM/chatglm3-6b--tokenization_chatglm.ChatGLMTokenizer",
      null
    ]
  },

to:

  "auto_map": {
    "AutoTokenizer": [
      "tokenization_chatglm.ChatGLMTokenizer",
      null
    ]
  },

This change should be made in the tokenizer_config.json file located in the directory of the chatglm3-6b model.

  1. Set the MODEL_ROOT_PATH: Ensure that MODEL_ROOT_PATH in your configuration file points to the absolute path where all your models, including chatglm3-6b and bge-large-zh-v1.5, are stored. If this path is not set or incorrect, the application cannot locate your offline models.

  2. Verify Model Directory Structure: The models should be in directories that match their keys in the MODEL_PATH dictionary or their repo_id as specified. For chatglm3-6b, the directory should be named THUDM/chatglm3-6b or simply chatglm3-6b if placed directly under MODEL_ROOT_PATH. Similarly, for bge-large-zh-v1.5, the directory should be named BAAI/bge-large-zh-v1.5 or simply bge-large-zh-v1.5.

  3. Update MODEL_PATH if Necessary: If your models are stored in a different structure than the default expected paths, update the MODEL_PATH dictionary in your configuration file to reflect the correct paths.

  4. Rename or Copy the Configuration File: If you haven't already, make sure to rename configs/model_config.py.example to configs/model_config.py (or the appropriate name expected by your application) and ensure your changes are saved in this file.

  5. Check Permissions: Ensure that the user running python3 startup.py -a has read access to the directories where the models are stored.

If you're still encountering issues, please provide more detailed information about your system setup and the exact error messages you're seeing. This will help in diagnosing the problem and providing a more specific solution.

Sources

#### About Dosu This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot.
cstkn commented 7 months ago

https://huggingface.co/BAAI/bge-large-zh 该文件应该放在哪里或者在哪里指定@dosu-bot

dosubot[bot] commented 7 months ago

Based on the context provided, it seems like you're having trouble with the placement of the model file downloaded from https://huggingface.co/BAAI/bge-large-zh. To ensure the model file is properly detected by your application and to avoid LocalEntryNotFoundError, OSError, and connection timeout errors when connecting to 'https://huggingface.co', you should place the model file in a directory under the path specified by MODEL_ROOT_PATH in your configs/model_config.py.example file.

The directory should be named either bge-large-zh or BAAI/bge-large-zh to match the key or value specified in the MODEL_PATH dictionary for the bge-large-zh model. If MODEL_ROOT_PATH is left as an empty string, you should define an absolute path for it where you prefer to store your models.

For example, if you decide to store your models in /path/to/models, you should:

  1. Set MODEL_ROOT_PATH = "/path/to/models" in your model_config.py.example file.
  2. Create a directory named bge-large-zh or BAAI/bge-large-zh under /path/to/models.
  3. Place the downloaded model file inside this directory.

This setup will allow your application to automatically detect and load the bge-large-zh model without needing to modify the MODEL_PATH dictionary or encountering errors due to missing models or failed connections to Hugging Face's servers.

You can refer to the following issues in the Langchain-Chatchat repository that have been resolved and are related to your problem:

  1. [BUG] 模型加载失败 报错:OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like THUDM/chatglm3-6b is not the path to a directory containing a file named configuration_chatglm.py.
  2. [BUG] 启动LLM_api.py失败
  3. [BUG] 更新后加载本地模型路径不正确

Please note that the default value of MODEL_ROOT_PATH in the configs/model_config.py.example file in the Langchain-Chatchat codebase is an empty string (""). You can find this information in the configs/model_config.py.example file.

I hope this helps! If you have any other questions or need further clarification, feel free to ask.

Sources

#### About Dosu This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot.
cstkn commented 7 months ago

@dosu-bot 我手动下载了https://huggingface.co/BAAI/bge-large-zh 中的文件,而不是用git,我应该将它们放在哪里,或在那个文件中修改路径,能保证这个baai文件能被正常识别

dosubot[bot] commented 7 months ago

Based on the context provided, here are the specific steps you can follow to manually download the model files from 'https://huggingface.co/BAAI/bge-large-zh' and correctly set the MODEL_ROOT_PATH in the configs/model_config.py.example file:

  1. Download the Model Files:

  2. Choose a Location for Model Files:

    • Decide on a directory where you want to store the model files. This directory will be referred to as <MODEL_DIRECTORY> in the following steps. For example, it could be something like /home/user/models/bge-large-zh.
  3. Place the Downloaded Files:

    • Place the downloaded model files into the <MODEL_DIRECTORY>.
  4. Modify the MODEL_ROOT_PATH in configs/model_config.py.example:

    • Open the file configs/model_config.py.example in a text editor.
    • Locate the line MODEL_ROOT_PATH = "".
    • Modify it to point to the parent directory of <MODEL_DIRECTORY>. If <MODEL_DIRECTORY> is /home/user/models/bge-large-zh, and /home/user/models is the directory where you plan to store all your models, then you should set MODEL_ROOT_PATH = "/home/user/models".
    MODEL_ROOT_PATH = "/home/user/models"
  5. Ensure Correct Model Path Configuration:

    • Given the context provided, the model configuration uses keys to map to specific model paths in the MODEL_PATH dictionary. Since you are using the model bge-large-zh, which is already specified in the MODEL_PATH dictionary under the embed_model key as "bge-large-zh": "BAAI/bge-large-zh", the program should automatically detect and load the model from the <MODEL_DIRECTORY> under MODEL_ROOT_PATH without further modifications, assuming the directory name matches the key or value specified in MODEL_PATH.

By following these steps, you should be able to avoid LocalEntryNotFoundError, OSError, and connection timeout errors related to loading the model locally, as the program will now use the local copy of the model files instead of trying to download them from 'https://huggingface.co'.

As for the structure of the MODEL_PATH dictionary in the configs/model_config.py.example file, it is structured into two main keys: embed_model and llm_model. Each of these keys maps to a dictionary where the keys are model identifiers (e.g., "ernie-tiny", "chatglm2-6b") and the values are either model paths or model names (e.g., "nghuyong/ernie-3.0-nano-zh", "THUDM/chatglm2-6b"). This structure allows for specifying the storage locations of local embedding models and LLM models, with support for both absolute paths and model names from repositories like Hugging Face.

MODEL_PATH = {
    "embed_model": {
        "ernie-tiny": "nghuyong/ernie-3.0-nano-zh",
        "ernie-base": "nghuyong/ernie-3.0-base-zh",
        ...
        "text-embedding-ada-002": "your OPENAI_API_KEY",
    },
    "llm_model": {
        "chatglm2-6b": "THUDM/chatglm2-6b",
        "chatglm2-6b-32k": "THUDM/chatglm2-6b-32k",
        ...
        "opt-iml-max-30b": "facebook/opt-iml-max-30b",
    }
}

You can refer to the configs/model_config.py.example file for more details.

I hope this helps! If you have any further questions or run into any issues, feel free to ask.

Sources

#### About Dosu This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot.
cstkn commented 7 months ago

@dosu-bot 现在出现了一下情况2024-03-01 20:34:29,490 - startup.py[line:655] - INFO: 正在启动服务: 2024-03-01 20:34:29,490 - startup.py[line:656] - INFO: 如需查看 llm_api 日志,请前往 D:\wujiaping\chatglm\langchain-chatchat\logs D:\wujiaping\chatglm.venv\Lib\site-packages\langchain_core_api\deprecation.py:117: LangChainDeprecationWarning: 模型启动功能将于 Langchain-Chatchat 0.3.x重写,支持更多模式和加速启动,0.2.x中相关功能将弃 warn_deprecated( 2024-03-01 20:34:33 | INFO | model_worker | Register to controller 2024-03-01 20:34:33 | ERROR | stderr | INFO: Started server process [28140] 2024-03-01 20:34:33 | ERROR | stderr | INFO: Waiting for application startup. 2024-03-01 20:34:33 | ERROR | stderr | INFO: Application startup complete. 2024-03-01 20:34:33 | ERROR | stderr | INFO: Uvicorn running on http://127.0.0.1:20000 (Press CTRL+C to quit) 2024-03-01 20:34:34 | INFO | model_worker | Loading the model ['chatglm3-6b'] on worker f219373d ... 2024-03-01 20:34:34 | WARNING | transformers_modules.chatglm3-6b.tokenization_chatglm | Setting eos_token is not supported, use the default one. 2024-03-01 20:34:34 | WARNING | transformers_modules.chatglm3-6b.tokenization_chatglm | Setting pad_token is not supported, use the default one. 2024-03-01 20:34:34 | WARNING | transformers_modules.chatglm3-6b.tokenization_chatglm | Setting unk_token is not supported, use the default one. Loading checkpoint shards: 0%| | 0/7 [00:00<?, ?it/s] Loading checkpoint shards: 14%|███████████████████▋ | 1/7 [00:00<00:05, 1.06it/s] Loading checkpoint shards: 29%|███████████████████████████████████████▍ | 2/7 [00:02<00:06, 1.20s/it] Loading checkpoint shards: 43%|███████████████████████████████████████████████████████████▏ | 3/7 [00:05<00:09, 2.27s/it] Loading checkpoint shards: 57%|██████████████████████████████████████████████████████████████████████████████▊ | 4/7 [00:14<00:13, 4.58s/it] Loading checkpoint shards: 71%|██████████████████████████████████████████████████████████████████████████████████████████████████▌ | 5/7 [00:30<00:17, 8.85s/it] Loading checkpoint shards: 86%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▎ | 6/7 [00:36<00:07, 7.95s/it] Loading checkpoint shards: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:38<00:00, 5.92s/it] Loading checkpoint shards: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:38<00:00, 5.48s/it] 2024-03-01 20:35:13 | ERROR | stderr | 2024-03-01 20:35:13 | ERROR | stderr | Process model_worker - chatglm3-6b: 2024-03-01 20:35:13 | ERROR | stderr | Traceback (most recent call last): 2024-03-01 20:35:13 | ERROR | stderr | File "C:\Users\lycor\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\process.py", line 314, in _bootstrap 2024-03-01 20:35:13 | ERROR | stderr | self.run() 2024-03-01 20:35:13 | ERROR | stderr | File "C:\Users\lycor\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\process.py", line 108, in run 2024-03-01 20:35:13 | ERROR | stderr | self._target(self._args, self._kwargs) 2024-03-01 20:35:13 | ERROR | stderr | File "D:\wujiaping\chatglm\langchain-chatchat\startup.py", line 389, in run_model_worker 2024-03-01 20:35:13 | ERROR | stderr | app = create_model_worker_app(log_level=log_level, kwargs) 2024-03-01 20:35:13 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 20:35:13 | ERROR | stderr | File "D:\wujiaping\chatglm\langchain-chatchat\startup.py", line 217, in create_model_worker_app 2024-03-01 20:35:13 | ERROR | stderr | worker = ModelWorker( 2024-03-01 20:35:13 | ERROR | stderr | ^^^^^^^^^^^^ 2024-03-01 20:35:13 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\fastchat\serve\model_worker.py", line 77, in init 2024-03-01 20:35:13 | ERROR | stderr | self.model, self.tokenizer = load_model( 2024-03-01 20:35:13 | ERROR | stderr | ^^^^^^^^^^^ 2024-03-01 20:35:13 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\fastchat\model\model_adapter.py", line 362, in load_model 2024-03-01 20:35:13 | ERROR | stderr | model.to(device) 2024-03-01 20:35:13 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\transformers\modeling_utils.py", line 2595, in to 2024-03-01 20:35:13 | ERROR | stderr | return super().to(args, **kwargs) 2024-03-01 20:35:13 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 20:35:13 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\torch\nn\modules\module.py", line 1160, in to 2024-03-01 20:35:13 | ERROR | stderr | return self._apply(convert) 2024-03-01 20:35:13 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^ 2024-03-01 20:35:13 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\torch\nn\modules\module.py", line 810, in _apply 2024-03-01 20:35:13 | ERROR | stderr | module._apply(fn) 2024-03-01 20:35:13 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\torch\nn\modules\module.py", line 810, in _apply 2024-03-01 20:35:13 | ERROR | stderr | module._apply(fn) 2024-03-01 20:35:13 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\torch\nn\modules\module.py", line 810, in _apply 2024-03-01 20:35:13 | ERROR | stderr | module._apply(fn) 2024-03-01 20:35:13 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\torch\nn\modules\module.py", line 833, in _apply 2024-03-01 20:35:13 | ERROR | stderr | param_applied = fn(param) 2024-03-01 20:35:13 | ERROR | stderr | ^^^^^^^^^ 2024-03-01 20:35:13 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\torch\nn\modules\module.py", line 1158, in convert 2024-03-01 20:35:13 | ERROR | stderr | return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking) 2024-03-01 20:35:13 | ERROR | stderr | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-03-01 20:35:13 | ERROR | stderr | File "D:\wujiaping\chatglm.venv\Lib\site-packages\torch\cuda__init__.py", line 289, in _lazy_init 2024-03-01 20:35:13 | ERROR | stderr | raise AssertionError("Torch not compiled with CUDA enabled") 2024-03-01 20:35:13 | ERROR | stderr | AssertionError: Torch not compiled with CUDA enabled

CodeSlogan commented 7 months ago

放在哪里没有特别的要求,把路径改对就行,路径在config目录下的model_config.py文件

cstkn commented 7 months ago

放在哪里没有特别的要求,把路径改对就行,路径在config目录下的model_config.py文件 bge-large-zh和chatglm3-6b都放到一个父目录里吗

zRzRzRzRzRzRzR commented 7 months ago

ssertionError: Torch not compiled with CUDA enabled 你环境都不对啊,检查环境吧

wangqinbo0609 commented 6 months ago

2024-03-07 21:02:10,494 - startup.py[line:655] - INFO: 正在启动服务: 2024-03-07 21:02:10,494 - startup.py[line:656] - INFO: 如需查看 llm_api 日志,请前往 D:\code\ai\windows_download\Langchain-Chatchat\logs C:\Users\wangqinbo\AppData\Local\Programs\Python\Python311\Lib\site-packages\langchain_core_api\deprecation.py:117: LangChainDeprecationWarning: 模型启动功能将于 Langchain-Chatchat 0.3.x重写,支持更多模式和加速启动,0.2.x中相关功能将废弃 warn_deprecated( 2024-03-07 21:02:26 | INFO | model_worker | Register to controller 2024-03-07 21:02:26 | ERROR | stderr | INFO: Started server process [2696] 2024-03-07 21:02:26 | ERROR | stderr | INFO: Waiting for application startup. 2024-03-07 21:02:26 | ERROR | stderr | INFO: Application startup complete. 2024-03-07 21:02:26 | ERROR | stderr | INFO: Uvicorn running on http://127.0.0.1:20000 (Press CTRL+C to quit) 2024-03-07 21:02:27 | INFO | model_worker | Loading the model ['chatglm3-6b'] on worker 8cc26e63 ... 2024-03-07 21:02:28 | WARNING | transformers_modules.chatglm3-6b.tokenization_chatglm | Setting eos_token is not supported, use the default one. 2024-03-07 21:02:28 | WARNING | transformers_modules.chatglm3-6b.tokenization_chatglm | Setting pad_token is not supported, use the default one. 2024-03-07 21:02:28 | WARNING | transformers_modules.chatglm3-6b.tokenization_chatglm | Setting unk_token is not supported, use the default one.

transformers_modules.chatglm3-6b.tokenization_chatglm | Setting unk_token is not supported, use the default one.