Files changed (1) hide show
  1. README.md +84 -72
README.md CHANGED
@@ -1,73 +1,85 @@
1
- ---
2
- language:
3
- - en
4
- base_model:
5
- - Qwen/Qwen2.5-7B-Instruct
6
- library_name: transformers
7
- ---
8
- ## Introduction
9
- 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.
10
- ## Requirements
11
- We advise you to use the latest version of `transformers`.
12
-
13
- ## Quickstart
14
-
15
- Given a query and a list of available tools. The model generate function calls using the provided tools to respond the query correctly.
16
-
17
- **Example query and tools format**
18
-
19
- ```python
20
- input_example=
21
- {
22
- "query": "Track crosschain message verification, implement timeout recovery procedures.",
23
- "tools": [
24
- {"type": "function", "function": {"name": "track_crosschain_message", "description": "Track the status of a crosschain message", "parameters": {"type": "object", "properties": {"message_id": {"type": "string"}}}}},
25
- {"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"}}}}}
26
- ]
27
- }
28
-
29
- ```
30
-
31
- **Function calling generation**
32
-
33
- ```python
34
- from transformers import AutoModelForCausalLM, AutoTokenizer
35
- import json
36
-
37
- model_name = "flock-io/Flock_Web3_Agent_Model"
38
- model = AutoModelForCausalLM.from_pretrained(
39
- model_name,
40
- torch_dtype="auto",
41
- device_map="auto"
42
- )
43
- tokenizer = AutoTokenizer.from_pretrained(model_name)
44
-
45
- messages = [
46
- {"role": "system", "content": "You are a helpful assistant with access to the following functions. Use them if required -"
47
- + json.dumps(input_example["tools"], ensure_ascii=False)},
48
- {"role": "user", "content": input_example["query"]}
49
- ]
50
- text = tokenizer.apply_chat_template(
51
- messages,
52
- tokenize=False,
53
- add_generation_prompt=True
54
- )
55
- model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
56
- generated_ids = model.generate(
57
- **model_inputs,
58
- max_new_tokens=3000
59
- )
60
- generated_ids = [
61
- output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
62
- ]
63
- response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
64
- ```
65
-
66
- The output text is in the string format
67
-
68
- ```
69
- [
70
- {"name": "track_crosschain_message", "arguments": {"message_id": "msg12345"}},
71
- {"name": "schedule_timeout_check", "arguments": {"message_id": "msg12345", "timeout": "30"}}
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
  ```