Unverified 提交 a70df988 作者: Zhi-guo Huang 提交者: GitHub

更新FAQ,model_config.py,bing_search.py文件,增加bing搜索问答相关问题的原因和可能解决方案,修复了一些typo;修改load…

更新FAQ,model_config.py,bing_search.py文件,增加bing搜索问答相关问题的原因和可能解决方案,修复了一些typo;修改loader.py中load_in_8bit失败的原因和详细解决方案 (#610)

* 修复 bing_search.py的typo;更新model_config.py中Bing Subscription Key申请方式及注意事项

* 更新FAQ,增加了[Errno 110] Connection timed out的原因与解决方案

* 修改loader.py中load_in_8bit失败的原因和详细解决方案

* update loader.py
上级 331f39cd
...@@ -7,7 +7,7 @@ from configs.model_config import BING_SEARCH_URL, BING_SUBSCRIPTION_KEY ...@@ -7,7 +7,7 @@ from configs.model_config import BING_SEARCH_URL, BING_SUBSCRIPTION_KEY
def bing_search(text, result_len=3): def bing_search(text, result_len=3):
if not (BING_SEARCH_URL and BING_SUBSCRIPTION_KEY): if not (BING_SEARCH_URL and BING_SUBSCRIPTION_KEY):
return [{"snippet": "please set BING_SUBSCRIPTION_KEY and BING_SEARCH_URL in os ENV", return [{"snippet": "please set BING_SUBSCRIPTION_KEY and BING_SEARCH_URL in os ENV",
"title": "env inof not fould", "title": "env info is not found",
"link": "https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html"}] "link": "https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html"}]
search = BingSearchAPIWrapper(bing_subscription_key=BING_SUBSCRIPTION_KEY, search = BingSearchAPIWrapper(bing_subscription_key=BING_SUBSCRIPTION_KEY,
bing_search_url=BING_SEARCH_URL) bing_search_url=BING_SEARCH_URL)
......
...@@ -163,7 +163,14 @@ flagging username: {FLAG_USER_NAME} ...@@ -163,7 +163,14 @@ flagging username: {FLAG_USER_NAME}
OPEN_CROSS_DOMAIN = False OPEN_CROSS_DOMAIN = False
# Bing 搜索必备变量 # Bing 搜索必备变量
# 使用 Bing 搜索需要使用 Bing Subscription Key # 使用 Bing 搜索需要使用 Bing Subscription Key,需要在azure port中申请试用bing search
# 具体申请方式请见 https://learn.microsoft.com/en-us/bing/search-apis/bing-web-search/quickstarts/rest/python # 具体申请方式请见
# https://learn.microsoft.com/en-us/bing/search-apis/bing-web-search/create-bing-search-service-resource
# 使用python创建bing api 搜索实例详见:
# https://learn.microsoft.com/en-us/bing/search-apis/bing-web-search/quickstarts/rest/python
BING_SEARCH_URL = "https://api.bing.microsoft.com/v7.0/search" BING_SEARCH_URL = "https://api.bing.microsoft.com/v7.0/search"
# 注意不是bing Webmaster Tools的api key,
# 此外,如果是在服务器上,报Failed to establish a new connection: [Errno 110] Connection timed out
# 是因为服务器加了防火墙,需要联系管理员加白名单,如果公司的服务器的话,就别想了GG
BING_SUBSCRIPTION_KEY = "" BING_SUBSCRIPTION_KEY = ""
\ No newline at end of file
...@@ -146,7 +146,6 @@ $ pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ ...@@ -146,7 +146,6 @@ $ pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/
$ pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/ $ pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
``` ```
Q12 启动api.py时upload_file接口抛出 `partially initialized module 'charset_normalizer' has no attribute 'md__mypyc' (most likely due to a circular import)` Q12 启动api.py时upload_file接口抛出 `partially initialized module 'charset_normalizer' has no attribute 'md__mypyc' (most likely due to a circular import)`
这是由于 charset_normalizer模块版本过高导致的,需要降低低charset_normalizer的版本,测试在charset_normalizer==2.1.0上可用。 这是由于 charset_normalizer模块版本过高导致的,需要降低低charset_normalizer的版本,测试在charset_normalizer==2.1.0上可用。
...@@ -174,3 +173,7 @@ download_with_progressbar(url, tmp_path) ...@@ -174,3 +173,7 @@ download_with_progressbar(url, tmp_path)
然后按照给定网址,如"https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_rec_infer.tar"手动下载文件,上传到对应的文件夹中,如“.paddleocr/whl/rec/ch/ch_PP-OCRv3_rec_infer/ch_PP-OCRv3_rec_infer.tar”. 然后按照给定网址,如"https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_rec_infer.tar"手动下载文件,上传到对应的文件夹中,如“.paddleocr/whl/rec/ch/ch_PP-OCRv3_rec_infer/ch_PP-OCRv3_rec_infer.tar”.
--- ---
Q14 调用api中的 `bing_search_chat`接口时,报出 `Failed to establish a new connection: [Errno 110] Connection timed out`
这是因为服务器加了防火墙,需要联系管理员加白名单,如果公司的服务器的话,就别想了GG--!
...@@ -30,6 +30,16 @@ class LoaderCheckPoint: ...@@ -30,6 +30,16 @@ class LoaderCheckPoint:
ptuning_dir: str = None ptuning_dir: str = None
use_ptuning_v2: bool = False use_ptuning_v2: bool = False
# 如果开启了8bit量化加载,项目无法启动,参考此位置,选择合适的cuda版本,https://github.com/TimDettmers/bitsandbytes/issues/156 # 如果开启了8bit量化加载,项目无法启动,参考此位置,选择合适的cuda版本,https://github.com/TimDettmers/bitsandbytes/issues/156
# 另一个原因可能是由于bitsandbytes安装时选择了系统环境变量里不匹配的cuda版本,
# 例如PATH下存在cuda10.2和cuda11.2,bitsandbytes安装时选择了10.2,而torch等安装依赖的版本是11.2
# 因此主要的解决思路是清理环境变量里PATH下的不匹配的cuda版本,一劳永逸的方法是:
# 0. 在终端执行`pip uninstall bitsandbytes`
# 1. 删除.bashrc文件下关于PATH的条目
# 2. 在终端执行 `echo $PATH >> .bashrc`
# 3. 删除.bashrc文件下PATH中关于不匹配的cuda版本路径
# 4. 在终端执行`source .bashrc`
# 5. 再执行`pip install bitsandbytes`
load_in_8bit: bool = False load_in_8bit: bool = False
is_llamacpp: bool = False is_llamacpp: bool = False
bf16: bool = False bf16: bool = False
...@@ -99,6 +109,8 @@ class LoaderCheckPoint: ...@@ -99,6 +109,8 @@ class LoaderCheckPoint:
LoaderClass = AutoModelForCausalLM LoaderClass = AutoModelForCausalLM
# Load the model in simple 16-bit mode by default # Load the model in simple 16-bit mode by default
# 如果加载没问题,但在推理时报错RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`
# 那还是因为显存不够,此时只能考虑--load-in-8bit,或者配置默认模型为`chatglm-6b-int8`
if not any([self.llm_device.lower() == "cpu", if not any([self.llm_device.lower() == "cpu",
self.load_in_8bit, self.is_llamacpp]): self.load_in_8bit, self.is_llamacpp]):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论