Improve language tag
#1
by
lbourdois
- opened
README.md
CHANGED
@@ -1,73 +1,85 @@
|
|
1 |
-
---
|
2 |
-
language:
|
3 |
-
-
|
4 |
-
|
5 |
-
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
)
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
)
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
```
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- zho
|
4 |
+
- eng
|
5 |
+
- fra
|
6 |
+
- spa
|
7 |
+
- por
|
8 |
+
- deu
|
9 |
+
- ita
|
10 |
+
- rus
|
11 |
+
- jpn
|
12 |
+
- kor
|
13 |
+
- vie
|
14 |
+
- tha
|
15 |
+
- ara
|
16 |
+
base_model:
|
17 |
+
- Qwen/Qwen2.5-7B-Instruct
|
18 |
+
library_name: transformers
|
19 |
+
---
|
20 |
+
## Introduction
|
21 |
+
FLock Web3 Agent Model is a specialized LLM designed to address complex queries in the Web3 ecosystem, with a focus on DeFi, blockchain interoperability, on-chain analytics, and etc.. The model excels in function-calling reasoning, enabling it to break down intricate user requests into actionable steps, interact with external APIs, and provide data-driven insights for Web3 applications. It is tailored for users ranging from developers and researchers to investors navigating the decentralized landscape.
|
22 |
+
## Requirements
|
23 |
+
We advise you to use the latest version of `transformers`.
|
24 |
+
|
25 |
+
## Quickstart
|
26 |
+
|
27 |
+
Given a query and a list of available tools. The model generate function calls using the provided tools to respond the query correctly.
|
28 |
+
|
29 |
+
**Example query and tools format**
|
30 |
+
|
31 |
+
```python
|
32 |
+
input_example=
|
33 |
+
{
|
34 |
+
"query": "Track crosschain message verification, implement timeout recovery procedures.",
|
35 |
+
"tools": [
|
36 |
+
{"type": "function", "function": {"name": "track_crosschain_message", "description": "Track the status of a crosschain message", "parameters": {"type": "object", "properties": {"message_id": {"type": "string"}}}}},
|
37 |
+
{"type": "function", "function": {"name": "schedule_timeout_check", "description": "Schedule a timeout check for a message", "parameters": {"type": "object", "properties": {"message_id": {"type": "string"}, "timeout": {"type": "integer"}}}}}
|
38 |
+
]
|
39 |
+
}
|
40 |
+
|
41 |
+
```
|
42 |
+
|
43 |
+
**Function calling generation**
|
44 |
+
|
45 |
+
```python
|
46 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
47 |
+
import json
|
48 |
+
|
49 |
+
model_name = "flock-io/Flock_Web3_Agent_Model"
|
50 |
+
model = AutoModelForCausalLM.from_pretrained(
|
51 |
+
model_name,
|
52 |
+
torch_dtype="auto",
|
53 |
+
device_map="auto"
|
54 |
+
)
|
55 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
56 |
+
|
57 |
+
messages = [
|
58 |
+
{"role": "system", "content": "You are a helpful assistant with access to the following functions. Use them if required -"
|
59 |
+
+ json.dumps(input_example["tools"], ensure_ascii=False)},
|
60 |
+
{"role": "user", "content": input_example["query"]}
|
61 |
+
]
|
62 |
+
text = tokenizer.apply_chat_template(
|
63 |
+
messages,
|
64 |
+
tokenize=False,
|
65 |
+
add_generation_prompt=True
|
66 |
+
)
|
67 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
68 |
+
generated_ids = model.generate(
|
69 |
+
**model_inputs,
|
70 |
+
max_new_tokens=3000
|
71 |
+
)
|
72 |
+
generated_ids = [
|
73 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
74 |
+
]
|
75 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
76 |
+
```
|
77 |
+
|
78 |
+
The output text is in the string format
|
79 |
+
|
80 |
+
```
|
81 |
+
[
|
82 |
+
{"name": "track_crosschain_message", "arguments": {"message_id": "msg12345"}},
|
83 |
+
{"name": "schedule_timeout_check", "arguments": {"message_id": "msg12345", "timeout": "30"}}
|
84 |
+
]
|
85 |
```
|