Skip to content

Commit 3dbaa96

Browse files
author
xusenlin
committed
tiny fix
1 parent 8e8587d commit 3dbaa96

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929

3030
支持多种开源大模型
3131

32-
| Model | Backbone | #Params | Open-source model | Open-source data | Claimed language | Post-training (instruction) | Post-training (conversation) | Release date |
33-
|-------------------------------------------------------------------------|----------|---------:|------------------:|-----------------:|-----------------:|----------------------------:|-----------------------------:|-------------:|
34-
| [ChatGLM](https://github.com/THUDM/ChatGLM-6B) | GLM | 6B | | | en, zh | | | 03/16/23 |
35-
| [BELLE](https://github.com/LianjiaTech/BELLE) | BLOOMZ | 7B | | | zh | 1.5M, zh | | 03/26/23 |
36-
| [Chinese-LLaMA-Alpaca](https://github.com/ymcui/Chinese-LLaMA-Alpaca) | LLaMA | 7/13B || | en, zh | 2M/3M, en/zh | | 03/28/23 |
37-
| [BAIZE](https://github.com/project-baize/baize-chatbot) | LLaMA | 7/13/30B | | | en | | 111.5K, en | 04/04/23 |
38-
| [Phoenix](https://github.com/FreedomIntelligence/LLMZoo) | BLOOMZ | 7B | | | multi | 40+ | 40+ | 04/08/23 |
39-
| [MOSS](https://github.com/OpenLMLab/MOSS) | CodeGen | 16B | | | en, zh | | | 04/21/23 |
32+
| Model | Backbone | #Params | Claimed language | Instruction-training | Conversation-training | checkpoint link |
33+
|:-----------------------------------------------------------------------|:----------:|:---------:|:-----------------:|:---------------------:|:----------------------:|:------------------------------------------------------------------------------------------------------------:|
34+
| [ChatGLM](https://github.com/THUDM/ChatGLM-6B) | GLM | 6B | en, zh | | | [THUDM/chatglm-6b](https://huggingface.co/THUDM/chatglm-6b) |
35+
| [BELLE](https://github.com/LianjiaTech/BELLE) | BLOOMZ | 7B | zh | 1.5M, zh | | [BelleGroup/BELLE-7B-2M](https://huggingface.co/BelleGroup/BELLE-7B-2M) |
36+
| [Chinese-LLaMA-Alpaca](https://github.com/ymcui/Chinese-LLaMA-Alpaca) | LLaMA | 7/13B | en, zh | 2M/3M, en/zh | | [ziqingyang/chinese-alpaca-plus-lora-7b](https://huggingface.co/ziqingyang/chinese-alpaca-plus-lora-7b) |
37+
| [BAIZE](https://github.com/project-baize/baize-chatbot) | LLaMA | 7/13/30B | en | | 111.5K, en | [project-baize/baize-lora-7B](https://huggingface.co/project-baize/baize-lora-7B) |
38+
| [Phoenix](https://github.com/FreedomIntelligence/LLMZoo) | BLOOMZ | 7B | multi | 40+ | 40+ | [FreedomIntelligence/phoenix-inst-chat-7b](https://huggingface.co/FreedomIntelligence/phoenix-inst-chat-7b) |
39+
| [MOSS](https://github.com/OpenLMLab/MOSS) | CodeGen | 16B | en, zh | | | [fnlp/moss-moon-003-sft-int4](https://huggingface.co/fnlp/moss-moon-003-sft-int4) |
4040

4141

4242
## 🐳 环境配置
@@ -112,12 +112,14 @@ python api/app.py \
112112
```shell
113113
cd applications/chat
114114

115-
python client.py --model_name chatglm
115+
python client.py --api_base http://192.168.0.xx:80/v1 --model_name chatglm
116116
```
117117

118+
![chat](images/chat.png)
119+
118120
### [openai-python](https://github.com/openai/openai-python)
119121

120-
#### Chat Completions
122+
#### 1. Chat Completions
121123

122124
```python
123125
import openai
@@ -140,7 +142,7 @@ print(completion.choices[0].message.content)
140142
# 你好👋!我是人工智能助手 ChatGLM-6B,很高兴见到你,欢迎问我任何问题。
141143
```
142144

143-
#### Completions
145+
#### 2. Completions
144146

145147
```python
146148
import openai
@@ -157,7 +159,7 @@ print(completion.choices[0].text)
157159
# 你好👋!我是人工智能助手 ChatGLM-6B,很高兴见到你,欢迎问我任何问题。
158160
```
159161

160-
#### Embeddings
162+
#### 3. Embeddings
161163

162164
```python
163165
import openai
@@ -178,7 +180,7 @@ print(embedding['data'][0]['embedding'])
178180

179181
### [langchain](https://github.com/hwchase17/langchain)
180182

181-
#### Chat Completions
183+
#### 1. Chat Completions
182184

183185
```python
184186
import os
@@ -194,7 +196,7 @@ print(chat([HumanMessage(content="你好")]))
194196
# content='你好👋!我是人工智能助手 ChatGLM-6B,很高兴见到你,欢迎问我任何问题。' additional_kwargs={}
195197
```
196198

197-
#### Completions
199+
#### 2. Completions
198200

199201
```python
200202
import os
@@ -209,7 +211,7 @@ print(llm("你好"))
209211
# 你好👋!我是人工智能助手 ChatGLM-6B,很高兴见到你,欢迎问我任何问题。
210212
```
211213

212-
#### Embeddings
214+
#### 3. Embeddings
213215

214216
```python
215217
import os

api/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ def load_model(self, model_name_or_path: str, adapter_model: Optional[str] = Non
7474

7575
if device != "cpu":
7676
model.to(device)
77-
model.eval()
77+
78+
model.eval()
7879

7980
return model, tokenizer
8081

applications/chat/client.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import os
2-
3-
os.environ["OPENAI_API_BASE"] = "http://192.168.0.xx:80/v1"
4-
os.environ["OPENAI_API_KEY"] = "xxx"
5-
61
import argparse
7-
from langchain.llms import OpenAI
2+
83
from langchain.callbacks.base import CallbackManager
94
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
105
from langchain.chains import ConversationChain
6+
from langchain.llms import OpenAI
117
from langchain.prompts import PromptTemplate
12-
from prompt import ChatPromptTEMPLATE
8+
139
from memory import CustomConversationBufferWindowMemory
10+
from prompt import ChatPromptTEMPLATE
1411

1512

1613
def main():
@@ -36,6 +33,9 @@ def main():
3633

3734
if __name__ == "__main__":
3835
parser = argparse.ArgumentParser(description="Chat server.")
36+
parser.add_argument(
37+
'--api_base', type=str, help='model api base', required=True,
38+
)
3939
parser.add_argument(
4040
'--model_name', type=str, help='chatglm, moss, phoenix, chinese-llama-alpaca', default='chatglm'
4141
)
@@ -44,4 +44,9 @@ def main():
4444
)
4545
args = parser.parse_args()
4646

47+
import os
48+
49+
os.environ["OPENAI_API_BASE"] = args.api_base
50+
os.environ["OPENAI_API_KEY"] = "xxx"
51+
4752
main()

images/chat.png

65.8 KB
Loading

0 commit comments

Comments
 (0)