Skip to content

Commit d682f61

Browse files
committed
更新readme
1 parent ca6b721 commit d682f61

File tree

2 files changed

+82
-132
lines changed

2 files changed

+82
-132
lines changed

README.md

Lines changed: 19 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
3. 重新适配了vllm对模型适配较差,导致解码内容和hf不对齐的问题。
2020
4. 支持了**vllm****LMDeploy****hf**的加载方式
2121
5. 支持所有兼容sentence_transformers的语义向量模型(Embedding和Reranker)
22-
6. 支持了Infinity后端,推理速度大于onnx/tensorrt,支持动态组批
23-
7. 支持guided_decoding,强制模型按照Schema的要求进行JSON格式输出。
24-
8. Chat模板无角色限制,使其完美支持了**LangGraph Agent**框架
25-
9. 支持多模态大模型
26-
10. **降低了模型适配的难度和项目使用的难度**(新模型的适配仅需修改低于5行代码),从而更容易的部署自己最新的模型。
22+
6. 支持了OpenAI接口规范的文本审核模型(text-moderation)
23+
7. 支持了Infinity后端,推理速度大于onnx/tensorrt,支持动态组批
24+
8. 支持guided_decoding,强制模型按照Schema的要求进行JSON格式输出。
25+
9. Chat模板无角色限制,使其完美支持了**LangGraph Agent**框架
26+
10. 支持多模态大模型
27+
11. **降低了模型适配的难度和项目使用的难度**(新模型的适配仅需修改低于5行代码),从而更容易的部署自己最新的模型。
2728

2829
(仓库初步构建中,构建过程中没有经过完善的回归测试,可能会发生已适配的模型不可用的Bug,欢迎提出改进或者适配模型的建议意见。)
2930

@@ -35,13 +36,16 @@
3536
1. 支持多种推理后端引擎,vLLM和LMDeploy,**LMDeploy**后端引擎,每秒处理的请求数是 vLLM 的 1.36 ~ 1.85 倍
3637
2. 支持了Infinity后端,推理速度大于onnx/tensorrt,支持动态组批
3738
3. 全球唯一完美支持**Tools(Function Calling)**功能的开源框架。兼容**LangChain****bind_tools****AgentExecutor****with_structured_output**写法(目前支持Qwen系列、GLM系列)
38-
4. 全球唯一扩展了**openai**库,实现Reranker模型。(代码样例见gpt_server/tests/test_openai_rerank.py)
39-
5. 支持多模态大模型
40-
6. 与FastChat相同的分布式架构
39+
4. 支持了**cohere**库接口规范的 /v1/rerank 接口
40+
5. 全球唯一扩展了**openai**库,实现Reranker模型。(代码样例见gpt_server/tests/test_openai_rerank.py)
41+
6. 全球唯一支持了**openai**库的文本审核模型接口(text-moderation)。(代码样例见gpt_server/tests/test_openai_moderation.py)
42+
7. 支持多模态大模型
43+
8. 与FastChat相同的分布式架构
4144

4245
## 更新信息
4346

4447
```plaintext
48+
2024-12-21 支持了 text-moderation 文本审核模型
4549
2024-12-14 支持了 phi-4
4650
2024-12-7 支持了 /v1/rerank 接口
4751
2024-12-1 支持了 QWQ-32B-Preview
@@ -78,7 +82,7 @@
7882
* [X] 支持多模态模型(初步支持glm-4v,其它模型后续慢慢支持)
7983
* [X] 支持Embedding模型动态组批(实现方式:infinity后端)
8084
* [X] 支持Reranker模型动态组批(实现方式:infinity后端)
81-
* [X] 可视化启动界面(不稳定)
85+
* [X] 可视化启动界面(不稳定,对开发人员来说比较鸡肋,后期将弃用!)
8286
* [ ] 支持 pip install 方式进行安装
8387
* [ ] 内置部分 tools (image_gen,code_interpreter,weather等)
8488
* [ ] 并行的function call功能(tools)
@@ -135,92 +139,7 @@ cd gpt_server/script
135139
vim config.yaml
136140
```
137141

138-
```yaml
139-
serve_args: # openai 服务的 host 和 pot
140-
host: 0.0.0.0
141-
port: 8082
142-
controller_address: http://localhost:21001 # 控制器的ip地址
143-
# api_keys: 111,222 # 用来设置 openai 密钥
144-
145-
# controller
146-
controller_args: # 控制器的配置参数
147-
host: 0.0.0.0
148-
port: 21001
149-
dispatch_method: shortest_queue # lottery、shortest_queue # 现有两种请求分发策略,随机(lottery) 和 最短队列(shortest_queue),最短队列方法更推荐。
150-
151-
# model worker
152-
model_worker_args: # 模型的配置参数,这里port 不能设置,程序自动分配,并注册到 控制器中。
153-
host: 0.0.0.0
154-
controller_address: http://localhost:21001 # 将模型注册到 控制器的 地址
155-
156-
models:
157-
- chatglm4: #自定义的模型名称
158-
alias: null # 别名 例如 gpt4,gpt3
159-
enable: true # false true 控制是否启动模型worker
160-
model_config:
161-
model_name_or_path: /home/dev/model/THUDM/glm-4-9b-chat/
162-
model_type: chatglm # qwen yi internlm
163-
work_mode: vllm # vllm hf lmdeploy-turbomind lmdeploy-pytorch
164-
# lora: # lora 配置
165-
# test_lora: /home/dev/project/LLaMA-Factory/saves/Qwen1.5-14B-Chat/lora/train_2024-03-22-09-01-32/checkpoint-100
166-
device: gpu # gpu / cpu
167-
workers:
168-
- gpus:
169-
# - 1
170-
- 0
171-
172-
# - gpus: 表示 模型使用 gpu[0,1],默认使用的 TP(张量并行)
173-
# - 0
174-
# - 1
175-
176-
# - gpus: 表示启动两个模型,模型副本1加载到 0卡, 模型副本2 加载到 1卡
177-
# - 0
178-
# - gpus:
179-
# - 1
180-
181-
182-
- qwen: #自定义的模型名称
183-
alias: gpt-4,gpt-3.5-turbo,gpt-3.5-turbo-16k # 别名 例如 gpt4,gpt3
184-
enable: true # false true 控制是否启动模型worker
185-
model_config:
186-
model_name_or_path: /home/dev/model/qwen/Qwen1___5-14B-Chat/
187-
enable_prefix_caching: false
188-
dtype: auto
189-
max_model_len: 65536
190-
model_type: qwen # qwen yi internlm
191-
work_mode: vllm # vllm hf lmdeploy-turbomind lmdeploy-pytorch
192-
device: gpu # gpu / cpu
193-
workers:
194-
- gpus:
195-
- 1
196-
# - gpus:
197-
# - 3
198-
199-
# Embedding 模型
200-
- bge-base-zh:
201-
alias: null # 别名
202-
enable: true # false true
203-
model_config:
204-
model_name_or_path: /home/dev/model/Xorbits/bge-base-zh-v1___5/
205-
model_type: embedding_infinity # embedding_infinity
206-
work_mode: hf
207-
device: gpu # gpu / cpu
208-
workers:
209-
- gpus:
210-
- 2
211-
# reranker 模型
212-
- bge-reranker-base:
213-
alias: null # 别名
214-
enable: true # false true 控制是否启动模型worker
215-
model_config:
216-
model_name_or_path: /home/dev/model/Xorbits/bge-reranker-base/
217-
model_type: embedding_infinity # embedding_infinity
218-
work_mode: hf
219-
device: gpu # gpu / cpu
220-
workers:
221-
- gpus:
222-
- 2
223-
```
142+
**配置文件的详细说明位于: https://github.com/shell-nlp/gpt_server/blob/main/gpt_server/script/config_example.yaml**
224143

225144
#### 3. 运行命令
226145

@@ -275,15 +194,15 @@ streamlit run server_ui.py
275194
| Qwen2-VL |qwen | × || × ||
276195
<br>
277196

278-
### Embedding模型
197+
### Embedding/Rerank/Classify模型
279198

280-
**原则上支持所有的Embedding/Rerank 模型**
199+
**原则上支持所有的Embedding/Rerank/Classify模型**
281200

282201
**推理速度:** Infinity >> HF
283202

284203
以下模型经过测试可放心使用:
285204

286-
| Embedding/Rerank | HF | Infinity |
205+
| Embedding/Rerank/Classify | HF | Infinity |
287206
| ------------------------- | -- | -------- |
288207
| bge-reranker |||
289208
| bce-reranker |||
@@ -296,6 +215,8 @@ streamlit run server_ui.py
296215
| zpoint_large_embedding_zh |||
297216
| xiaobu-embedding |||
298217
|Conan-embedding-v1 |||
218+
|KoalaAI/Text-Moderation | × ||
219+
|protectai/deberta-v3-base-prompt-injection-v2| × ||
299220

300221
目前 TencentBAC的 **Conan-embedding-v1** C-MTEB榜单排行第一(MTEB: https://huggingface.co/spaces/mteb/leaderboard)
301222

gpt_server/script/config_example.yaml

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,82 @@
11
# 后台启动 nohup sh start.sh > gptserver.log &
22
# openai_api_server
33
serve_args:
4+
# openai 服务的 host 和 port
45
host: 0.0.0.0
56
port: 8082
6-
controller_address: http://localhost:21001
7-
# api_keys: 111,222
7+
controller_address: http://localhost:21001 # 控制器的ip地址
8+
# api_keys: 111,222 # 用来设置 openai 密钥
9+
810

9-
# controller
1011
controller_args:
12+
# 控制器的配置参数
1113
host: 0.0.0.0
1214
port: 21001
13-
dispatch_method: shortest_queue # lottery shortest_queue
15+
dispatch_method: shortest_queue # lottery、shortest_queue # 现有两种请求分发策略,随机(lottery) 和 最短队列(shortest_queue),最短队列方法更推荐。
1416

15-
# model worker
1617
model_worker_args:
18+
# 模型的配置参数,这里port 不能设置,程序自动分配,并注册到 控制器中。
19+
# model worker 的配置参数
1720
host: 0.0.0.0
18-
controller_address: http://localhost:21001
21+
controller_address: http://localhost:21001 # # 将模型注册到 控制器的 地址
1922

2023
models:
21-
- internvl2: #自定义的模型名称
22-
alias: null # 别名 例如 gpt4,gpt3
24+
- qwen:
25+
# 大语言模型
26+
#自定义的模型名称
27+
alias: gpt-4,gpt-3.5-turbo,gpt-3.5-turbo-16k # 别名 例如 gpt4,gpt3
2328
enable: false # false true
2429
model_config:
25-
model_name_or_path: /home/dev/model/OpenGVLab/InternVL2-40B-AWQ/
26-
enable_prefix_caching: false
27-
model_type: internvl2 # qwen yi internlm
30+
# 模型的配置参数
31+
model_name_or_path: /home/dev/model/qwen/Qwen2___5-7B-Instruct/ # 模型的路径
32+
enable_prefix_caching: true # 是否启用前缀缓存
33+
dtype: auto # 类型
34+
max_model_len: 65536 # 模型最大token 长度
35+
# lora: # lora 模型的路径
36+
# test_lora: /home/dev/project/LLaMA-Factory/saves/Qwen1.5-14B-Chat/lora/train_2024-03-22-09-01-32/checkpoint-100
37+
38+
model_type: qwen # qwen yi internlm 等
2839
work_mode: lmdeploy-turbomind # vllm hf lmdeploy-turbomind lmdeploy-pytorch
40+
2941
device: gpu # gpu / cpu
3042
workers:
3143
- gpus:
32-
# - 1
33-
- 0
44+
- 1
45+
# - gpus:
46+
# - 3
3447
# - gpus:
3548
# - 0
3649

37-
- qwen: #自定义的模型名称
38-
alias: gpt-4,gpt-3.5-turbo,gpt-3.5-turbo-16k # 别名 例如 gpt4,gpt3
39-
enable: false # false true
40-
model_config:
41-
model_name_or_path: /home/dev/model/qwen/Qwen2___5-7B-Instruct/
42-
enable_prefix_caching: true
43-
dtype: auto
44-
max_model_len: 65536
45-
# lora:
46-
# test_lora: /home/dev/project/LLaMA-Factory/saves/Qwen1.5-14B-Chat/lora/train_2024-03-22-09-01-32/checkpoint-100
50+
# - gpus: 表示 模型使用 gpu[0,1],默认使用的 TP(张量并行)
51+
# - 0
52+
# - 1
53+
54+
# - gpus: 表示启动两个模型,模型副本1加载到 0卡, 模型副本2 加载到 1卡
55+
# - 0
56+
# - gpus:
57+
# - 1
58+
4759

48-
model_type: qwen # qwen yi internlm
49-
work_mode: lmdeploy-turbomind # vllm hf lmdeploy-turbomind lmdeploy-pytorch
5060

61+
- internvl2:
62+
# 多模态模型
63+
#自定义的模型名称
64+
alias: null # 别名 例如 gpt4,gpt3
65+
enable: false # false true 控制是否启动模型worker
66+
model_config:
67+
# 模型的配置参数
68+
model_name_or_path: /home/dev/model/OpenGVLab/InternVL2-40B-AWQ/
69+
enable_prefix_caching: false
70+
model_type: internvl2 # qwen yi internlm
71+
work_mode: lmdeploy-turbomind # vllm hf lmdeploy-turbomind lmdeploy-pytorch
5172
device: gpu # gpu / cpu
5273
workers:
5374
- gpus:
54-
- 1
55-
# - gpus:
56-
# - 3
75+
# - 1
76+
- 0
5777

5878
- bge-reranker-base:
79+
# rerank模型
5980
alias: null # 别名
6081
enable: true # false true
6182
model_config:
@@ -66,7 +87,9 @@ models:
6687
workers:
6788
- gpus:
6889
- 2
90+
6991
- acge_text_embedding:
92+
# 文本embedding模型
7093
alias: text-embedding-ada-002 # 别名
7194
enable: true # false true
7295
model_config:
@@ -78,9 +101,15 @@ models:
78101
- gpus:
79102
- 2
80103

81-
82-
83-
84-
85-
86-
104+
- text-moderation:
105+
# 文本审核模型
106+
alias: omni-moderation-latest
107+
enable: true
108+
model_config:
109+
model_name_or_path: /home/dev/model/KoalaAI/Text-Moderation
110+
model_type: embedding_infinity
111+
work_mode: hf
112+
device: gpu
113+
workers:
114+
- gpus:
115+
- 2

0 commit comments

Comments
 (0)