Skip to content

Commit

Permalink
feat(service): fix requirements.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoisonooo committed Jan 12, 2024
1 parent 4d57258 commit 3d07873
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
11 changes: 9 additions & 2 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ cd HuixiangDou && mkdir workdir # 创建工作目录
python3 -m pip install -r requirements.txt # 安装依赖,python3.11 需要 `conda install conda-forge::faiss-gpu`
python3 service/feature_store.py # 把 repodir 的特征保存到 workdir
```
首次运行将自动下载配置中的 [text2vec-large-chinese](https://huggingface.co/GanymedeNil/text2vec-large-chinese),如果自动下载失败,可以手动下载到本地,然后在 `config.ini` 设置模型路径。
首次运行将自动下载配置中的 [text2vec-large-chinese](https://huggingface.co/GanymedeNil/text2vec-large-chinese)。考虑到不同地区 huggingface 连接问题,建议先手动下载到本地,然后在 `config.ini` 设置模型路径。例如:

结束后,茴香豆能够区分应该处理哪些用户话题,哪些闲聊应该拒绝。请编辑 [good_questions](./resource/good_questions.json)[bad_questions](./resource/bad_questions.json),尝试自己的领域知识(医疗,金融,电力等)。
```shell
# config.ini
[feature_store]
..
model_path = "/path/to/text2vec-large-chinese"
```

运行结束后,茴香豆能够区分应该处理哪些用户话题,哪些闲聊应该拒绝。请编辑 [good_questions](./resource/good_questions.json)[bad_questions](./resource/bad_questions.json),尝试自己的领域知识(医疗,金融,电力等)。

```shell
# 接受技术话题
Expand Down
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ sentence_transformers
readability-lxml
faiss-gpu
transformers>=4.33.2
openai>=1.0.0
pydantic>=1.10.13
transformers_stream_generator
accelerate>=0.26.1
beautifulsoup4
tiktoken
einops
3 changes: 2 additions & 1 deletion service/llm_server_hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def __init__(self,
model_path,
trust_remote_code=True,
device_map="auto",
# fp16=True,
# torch_dtype="auto",
# fp16=True,
).eval()
else:
logger.warning(f'local LLM disabled.')
Expand Down
2 changes: 1 addition & 1 deletion service/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def generate(self, query, history, groupname):
response = self.llm.generate_response(prompt=prompt,
history=history,
remote=True)
tracker.track('feature store doc', [db_context_part, response])
tracker.log('feature store doc', [db_context_part, response])
return ErrorCode.SUCCESS, response

else:
Expand Down
12 changes: 12 additions & 0 deletions tests/test_hf_import_accelerate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from accelerate import dispatch_model, infer_auto_device_map, init_empty_weights
from accelerate.hooks import add_hook_to_module
from accelerate.utils import (
check_tied_parameters_on_same_device,
find_tied_parameters,
get_balanced_memory,
get_max_memory,
load_offloaded_weights,
offload_weight,
save_offload_index,
set_module_tensor_to_device,
)

0 comments on commit 3d07873

Please sign in to comment.