本地化bge-m3模型
我在运行api_server.py代码时https://github.com/THUDM/ChatGLM3/blob/main/openai_api_demo/api_server.py,源码会用到该模型。但是无法从hugginface下载,请问该怎么办?
EMBEDDING_PATH = os.environ.get('EMBEDDING_PATH', 'BAAI/bge-m3')
以下是全部报错信息:
Setting eos_token is not supported, use the default one.
Setting pad_token is not supported, use the default one.
Setting unk_token is not supported, use the default one.
Loading checkpoint shards: 100%|██████████| 7/7 [00:13<00:00, 1.93s/it]
No sentence-transformers model found with name BAAI/bge-m3. Creating a new one with mean pooling.
/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/huggingface_hub/file_download.py:1150: FutureWarning: resume_download
is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use force_download=True
.
warnings.warn(
Traceback (most recent call last):
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/urllib3/connection.py", line 196, in _new_conn
sock = connection.create_connection(
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/urllib3/util/connection.py", line 85, in create_connection
raise err
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
OSError: [Errno 101] Network is unreachable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/urllib3/connectionpool.py", line 789, in urlopen
response = self._make_request(
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/urllib3/connectionpool.py", line 490, in _make_request
raise new_e
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/urllib3/connectionpool.py", line 466, in _make_request
self._validate_conn(conn)
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1095, in _validate_conn
conn.connect()
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/urllib3/connection.py", line 615, in connect
self.sock = sock = self._new_conn()
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/urllib3/connection.py", line 211, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f3921a05dc0>: Failed to establish a new connection: [Errno 101] Network is unreachable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/requests/adapters.py", line 667, in send
resp = conn.urlopen(
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/urllib3/connectionpool.py", line 843, in urlopen
retries = retries.increment(
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/urllib3/util/retry.py", line 519, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /BAAI/bge-m3/resolve/main/config.json (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f3921a05dc0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 1751, in _get_metadata_or_catch_error
metadata = get_hf_file_metadata(
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 1673, in get_hf_file_metadata
r = _request_wrapper(
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 376, in _request_wrapper
response = _request_wrapper(
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 399, in _request_wrapper
response = get_session().request(method=method, url=url, **params)
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/huggingface_hub/utils/_http.py", line 66, in send
return super().send(request, *args, **kwargs)
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/requests/adapters.py", line 700, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /BAAI/bge-m3/resolve/main/config.json (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f3921a05dc0>: Failed to establish a new connection: [Errno 101] Network is unreachable'))"), '(Request ID: 2df00201-b4c8-4767-bc87-73c107e04c4a)')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/transformers/utils/hub.py", line 398, in cached_file
resolved_file = hf_hub_download(
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/huggingface_hub/utils/_deprecation.py", line 101, in inner_f
return f(*args, **kwargs)
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 1240, in hf_hub_download
return _hf_hub_download_to_cache_dir(
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 1347, in _hf_hub_download_to_cache_dir
_raise_on_head_call_error(head_call_error, force_download, local_files_only)
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/huggingface_hub/file_download.py", line 1857, in _raise_on_head_call_error
raise LocalEntryNotFoundError(
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.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/ycw/ChatGLM3/openai_api_demo/api_server_cpu.py", line 541, in
embedding_model = SentenceTransformer(EMBEDDING_PATH, device="cuda")
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/sentence_transformers/SentenceTransformer.py", line 299, in init
modules = self._load_auto_model(
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/sentence_transformers/SentenceTransformer.py", line 1324, in _load_auto_model
transformer_model = Transformer(
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/sentence_transformers/models/Transformer.py", line 53, in init
config = AutoConfig.from_pretrained(model_name_or_path, **config_args, cache_dir=cache_dir)
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/transformers/models/auto/configuration_auto.py", line 928, in from_pretrained
config_dict, unused_kwargs = PretrainedConfig.get_config_dict(pretrained_model_name_or_path, **kwargs)
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/transformers/configuration_utils.py", line 631, in get_config_dict
config_dict, kwargs = cls._get_config_dict(pretrained_model_name_or_path, **kwargs)
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/transformers/configuration_utils.py", line 686, in _get_config_dict
resolved_config_file = cached_file(
File "/root/miniconda3/envs/shorthand/lib/python3.9/site-packages/transformers/utils/hub.py", line 441, in cached_file
raise EnvironmentError(
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 BAAI/bge-m3 is not the path to a directory containing a file named config.json.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.
我的也是这个样子,我试过了本地下载完上传到我的服务器上,运行也不行,有没有解决方法
有梯子的话建议
import os
os.environ['http_proxy']='http://xxxx:xxxx'
os.environ['https_proxy']='http://xxxx:xxxx'
可以使用镜像网站,https://hf-mirror.com/