zzp-seeker
commited on
Commit
•
57e1bd9
1
Parent(s):
4320784
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,89 @@
|
|
1 |
---
|
2 |
-
license: cc-by-nd-4.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
license: cc-by-nc-nd-4.0
|
3 |
+
datasets:
|
4 |
+
- kwaikeg/KAgentInstruct
|
5 |
+
- kwaikeg/KAgentBench
|
6 |
+
language:
|
7 |
+
- en
|
8 |
+
- zh
|
9 |
+
pipeline_tag: text-generation
|
10 |
---
|
11 |
+
|
12 |
+
|
13 |
+
KwaiAgents ([Github](https://github.com/KwaiKEG/KwaiAgents)) is a series of Agent-related works open-sourced by the [KwaiKEG](https://github.com/KwaiKEG) from [Kuaishou Technology](https://www.kuaishou.com/en). The open-sourced content includes:
|
14 |
+
|
15 |
+
1. **KAgentSys-Lite**: An experimental Agent Loop implemented based on open-source search engines, browsers, time, calendar, weather, and other tools, which is only missing the memory mechanism and some search capabilities compared to the system in the paper.
|
16 |
+
2. **KAgentLMs**: A series of large language models with Agent capabilities such as planning, reflection, and tool-use, acquired through the Meta-agent tuning proposed in the paper.
|
17 |
+
3. **KAgentInstruct**: Fine-tuned data of instructions generated by the Meta-agent in the paper.
|
18 |
+
4. **KAgentBench**: Over 3,000 human-edited, automated evaluation data for testing Agent capabilities, with evaluation dimensions including planning, tool-use, reflection, concluding, and profiling.
|
19 |
+
|
20 |
+
|
21 |
+
## User Guide
|
22 |
+
|
23 |
+
NOTE: Qwen1.5_14b_mat is located in the master branch.
|
24 |
+
|
25 |
+
### Direct usage
|
26 |
+
|
27 |
+
Tutorial can refer to [QwenLM/Qwen](https://github.com/QwenLM/Qwen)
|
28 |
+
```python
|
29 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
30 |
+
from transformers.generation import GenerationConfig
|
31 |
+
|
32 |
+
tokenizer = AutoTokenizer.from_pretrained("kwaikeg/kagentlms_qwen_7b_mat", trust_remote_code=True)
|
33 |
+
|
34 |
+
model = AutoModelForCausalLM.from_pretrained(
|
35 |
+
"kwaikeg/kagentlms_qwen1.5_14b_mat",
|
36 |
+
device_map="auto",
|
37 |
+
trust_remote_code=True
|
38 |
+
).eval()
|
39 |
+
|
40 |
+
response, history = model.chat(tokenizer, "你好", history=None)
|
41 |
+
print(response)
|
42 |
+
```
|
43 |
+
|
44 |
+
### AgentLMs as service
|
45 |
+
We recommend using [vLLM](https://github.com/vllm-project/vllm) and [FastChat](https://github.com/lm-sys/FastChat) to deploy the model inference service. First, you need to install the corresponding packages (for detailed usage, please refer to the documentation of the two projects):
|
46 |
+
```bash
|
47 |
+
pip install vllm
|
48 |
+
pip install "fschat[model_worker,webui]"
|
49 |
+
```
|
50 |
+
To deploy KAgentLMs, you first need to start the controller in one terminal.
|
51 |
+
```bash
|
52 |
+
python -m fastchat.serve.controller
|
53 |
+
```
|
54 |
+
Secondly, you should use the following command in another terminal for single-gpu inference service deployment:
|
55 |
+
```bash
|
56 |
+
python -m fastchat.serve.vllm_worker --model-path $model_path --trust-remote-code
|
57 |
+
```
|
58 |
+
Where `$model_path` is the local path of the model downloaded. If the GPU does not support Bfloat16, you can add `--dtype half` to the command line.
|
59 |
+
|
60 |
+
Thirdly, start the REST API server in the third terminal.
|
61 |
+
```bash
|
62 |
+
python -m fastchat.serve.openai_api_server --host localhost --port 8888
|
63 |
+
```
|
64 |
+
|
65 |
+
Finally, you can use the curl command to invoke the model same as the OpenAI calling format. Here's an example:
|
66 |
+
```bash
|
67 |
+
curl http://localhost:8888/v1/chat/completions \
|
68 |
+
-H "Content-Type: application/json" \
|
69 |
+
-d '{"model": "kagentlms_qwen_7b_mat", "messages": [{"role": "user", "content": "Who is Andy Lau"}]}'
|
70 |
+
```
|
71 |
+
|
72 |
+
### Citation
|
73 |
+
```
|
74 |
+
@article{pan2023kwaiagents,
|
75 |
+
author = {Haojie Pan and
|
76 |
+
Zepeng Zhai and
|
77 |
+
Hao Yuan and
|
78 |
+
Yaojia Lv and
|
79 |
+
Ruiji Fu and
|
80 |
+
Ming Liu and
|
81 |
+
Zhongyuan Wang and
|
82 |
+
Bing Qin
|
83 |
+
},
|
84 |
+
title = {KwaiAgents: Generalized Information-seeking Agent System with Large Language Models},
|
85 |
+
journal = {CoRR},
|
86 |
+
volume = {abs/2312.04889},
|
87 |
+
year = {2023}
|
88 |
+
}
|
89 |
+
```
|