myscarlet commited on
Commit
7dbbf5e
1 Parent(s): 66c453e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +68 -1
README.md CHANGED
@@ -7,4 +7,71 @@ language:
7
  - en
8
  - zh
9
  pipeline_tag: text-generation
10
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ### Direct usage
24
+
25
+ Tutorial can refer to [QwenLM/Qwen](https://github.com/QwenLM/Qwen)
26
+ ```python
27
+ from transformers import AutoModelForCausalLM, AutoTokenizer
28
+ from transformers.generation import GenerationConfig
29
+
30
+ tokenizer = AutoTokenizer.from_pretrained("kwaikeg/kagentlms_qwen_7b_mat", trust_remote_code=True)
31
+
32
+ model = AutoModelForCausalLM.from_pretrained(
33
+ "kwaikeg/kagentlms_qwen_7b_mat",
34
+ device_map="auto",
35
+ trust_remote_code=True
36
+ ).eval()
37
+
38
+ response, history = model.chat(tokenizer, "你好", history=None)
39
+ print(response)
40
+ ```
41
+
42
+ ### AgentLMs as service
43
+ 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):
44
+ 1. For Qwen-7B-MAT, install the corresponding packages with the following commands
45
+ ```bash
46
+ pip install vllm
47
+ pip install "fschat[model_worker,webui]"
48
+ ```
49
+ 2. For Baichuan-13B-MAT, install the corresponding packages with the following commands
50
+ ```bash
51
+ pip install "fschat[model_worker,webui]"
52
+ pip install vllm==0.2.0
53
+ pip install transformers==4.33.2
54
+ ```
55
+
56
+ To deploy KAgentLMs, you first need to start the controller in one terminal.
57
+ ```bash
58
+ python -m fastchat.serve.controller
59
+ ```
60
+ Secondly, you should use the following command in another terminal for single-gpu inference service deployment:
61
+ ```bash
62
+ python -m fastchat.serve.vllm_worker --model-path $model_path --trust-remote-code
63
+ ```
64
+ 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.
65
+
66
+ Thirdly, start the REST API server in the third terminal.
67
+ ```bash
68
+ python -m fastchat.serve.openai_api_server --host localhost --port 8888
69
+ ```
70
+
71
+ Finally, you can use the curl command to invoke the model same as the OpenAI calling format. Here's an example:
72
+ ```bash
73
+ curl http://localhost:8888/v1/chat/completions \
74
+ -H "Content-Type: application/json" \
75
+ -d '{"model": "kagentlms_qwen_7b_mat", "messages": [{"role": "user", "content": "Who is Andy Lau"}]}'
76
+ ```
77
+ Here, change `kagentlms_qwen_7b_mat` to the model you deployed.