Skip to content

Commit

Permalink
更新FAQ,model_config.py,bing_search.py文件,增加bing搜索问答相关问题的原因和可能解决方案,修复了一些…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
hzg0601 authored Jun 14, 2023
1 parent 331f39c commit a70df98
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion agent/bing_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def bing_search(text, result_len=3):
if not (BING_SEARCH_URL and BING_SUBSCRIPTION_KEY):
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"}]
search = BingSearchAPIWrapper(bing_subscription_key=BING_SUBSCRIPTION_KEY,
bing_search_url=BING_SEARCH_URL)
Expand Down
11 changes: 9 additions & 2 deletions configs/model_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,14 @@
OPEN_CROSS_DOMAIN = False

# Bing 搜索必备变量
# 使用 Bing 搜索需要使用 Bing Subscription Key
# 具体申请方式请见 https://learn.microsoft.com/en-us/bing/search-apis/bing-web-search/quickstarts/rest/python
# 使用 Bing 搜索需要使用 Bing Subscription Key,需要在azure port中申请试用bing search
# 具体申请方式请见
# 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 Webmaster Tools的api key,

# 此外,如果是在服务器上,报Failed to establish a new connection: [Errno 110] Connection timed out
# 是因为服务器加了防火墙,需要联系管理员加白名单,如果公司的服务器的话,就别想了GG
BING_SUBSCRIPTION_KEY = ""
5 changes: 4 additions & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
```


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上可用。
Expand Down Expand Up @@ -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”.

---

Q14 调用api中的 `bing_search_chat`接口时,报出 `Failed to establish a new connection: [Errno 110] Connection timed out`

这是因为服务器加了防火墙,需要联系管理员加白名单,如果公司的服务器的话,就别想了GG--!
12 changes: 12 additions & 0 deletions models/loader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ class LoaderCheckPoint:
ptuning_dir: str = None
use_ptuning_v2: bool = False
# 如果开启了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
is_llamacpp: bool = False
bf16: bool = False
Expand Down Expand Up @@ -99,6 +109,8 @@ def _load_model(self, model_name):
LoaderClass = AutoModelForCausalLM

# 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",
self.load_in_8bit, self.is_llamacpp]):

Expand Down

0 comments on commit a70df98

Please sign in to comment.