Zack Li commited on
Commit
c11c4b2
1 Parent(s): 21f6fbf

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +90 -224
README.md CHANGED
@@ -1,233 +1,99 @@
1
- ## Model Configuration
2
-
3
- ### Base Model
4
-
5
- ```json
6
- {
7
- "base_model": "google/gemma-7b-it"
8
- }
9
- ```
10
-
11
- ### LoRA Configuration
12
-
13
- ```json
14
- {
15
- "lora_config": {
16
- "lora_alpha": 32,
17
- "lora_dropout": 0.05,
18
- "lora_r": 16,
19
- "lora_modulus": [
20
- "q_proj",
21
- "v_proj",
22
- "o_proj",
23
- "up_proj",
24
- "down_proj"
25
- ]
26
- }
27
- }
28
- ```
29
-
30
- ### Experiment Tracking
31
-
32
- - **Weights & Biases Run**: [View Run Details](https://wandb.ai/nexaai/nexa-sft-alex/runs/2fzr2wx9)
33
-
34
  ---
35
 
36
- This format provides a clear separation between the model's base configuration, the specific LoRA configuration, and a link to the experiment tracking, making it easier to understand and navigate.
37
-
38
- # Model Card for Model ID
39
-
40
- <!-- Provide a quick summary of what the model is/does. -->
41
-
42
-
43
-
44
- ## Model Details
45
-
46
- ### Model Description
47
-
48
- <!-- Provide a longer summary of what this model is. -->
49
-
50
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
51
-
52
- - **Developed by:** [More Information Needed]
53
- - **Funded by [optional]:** [More Information Needed]
54
- - **Shared by [optional]:** [More Information Needed]
55
- - **Model type:** [More Information Needed]
56
- - **Language(s) (NLP):** [More Information Needed]
57
- - **License:** [More Information Needed]
58
- - **Finetuned from model [optional]:** [More Information Needed]
59
-
60
- ### Model Sources [optional]
61
-
62
- <!-- Provide the basic links for the model. -->
63
-
64
- - **Repository:** [More Information Needed]
65
- - **Paper [optional]:** [More Information Needed]
66
- - **Demo [optional]:** [More Information Needed]
67
-
68
- ## Uses
69
-
70
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
71
-
72
- ### Direct Use
73
-
74
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
75
-
76
- [More Information Needed]
77
-
78
- ### Downstream Use [optional]
79
-
80
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
81
-
82
- [More Information Needed]
83
-
84
- ### Out-of-Scope Use
85
-
86
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
87
-
88
- [More Information Needed]
89
-
90
- ## Bias, Risks, and Limitations
91
-
92
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
93
-
94
- [More Information Needed]
95
-
96
- ### Recommendations
97
-
98
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
99
-
100
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
101
-
102
- ## How to Get Started with the Model
103
-
104
- Use the code below to get started with the model.
105
-
106
- [More Information Needed]
107
-
108
- ## Training Details
109
-
110
- ### Training Data
111
-
112
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
113
-
114
- [More Information Needed]
115
-
116
- ### Training Procedure
117
-
118
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
119
-
120
- #### Preprocessing [optional]
121
-
122
- [More Information Needed]
123
-
124
-
125
- #### Training Hyperparameters
126
-
127
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
128
-
129
- #### Speeds, Sizes, Times [optional]
130
-
131
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
132
-
133
- [More Information Needed]
134
 
135
  ## Evaluation
 
 
 
 
136
 
137
- <!-- This section describes the evaluation protocols and provides the results. -->
138
-
139
- ### Testing Data, Factors & Metrics
140
-
141
- #### Testing Data
142
-
143
- <!-- This should link to a Dataset Card if possible. -->
144
-
145
- [More Information Needed]
146
-
147
- #### Factors
148
-
149
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
150
-
151
- [More Information Needed]
152
-
153
- #### Metrics
154
-
155
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
156
-
157
- [More Information Needed]
158
-
159
- ### Results
160
-
161
- [More Information Needed]
162
-
163
- #### Summary
164
-
165
-
166
-
167
- ## Model Examination [optional]
168
-
169
- <!-- Relevant interpretability work for the model goes here -->
170
-
171
- [More Information Needed]
172
-
173
- ## Environmental Impact
174
-
175
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
176
-
177
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
178
-
179
- - **Hardware Type:** [More Information Needed]
180
- - **Hours used:** [More Information Needed]
181
- - **Cloud Provider:** [More Information Needed]
182
- - **Compute Region:** [More Information Needed]
183
- - **Carbon Emitted:** [More Information Needed]
184
-
185
- ## Technical Specifications [optional]
186
 
187
- ### Model Architecture and Objective
188
 
189
- [More Information Needed]
190
-
191
- ### Compute Infrastructure
192
-
193
- [More Information Needed]
194
-
195
- #### Hardware
196
-
197
- [More Information Needed]
198
-
199
- #### Software
200
-
201
- [More Information Needed]
202
-
203
- ## Citation [optional]
204
-
205
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
206
-
207
- **BibTeX:**
208
-
209
- [More Information Needed]
210
-
211
- **APA:**
212
-
213
- [More Information Needed]
214
-
215
- ## Glossary [optional]
216
-
217
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
218
-
219
- [More Information Needed]
220
-
221
- ## More Information [optional]
222
-
223
- [More Information Needed]
224
-
225
- ## Model Card Authors [optional]
226
-
227
- [More Information Needed]
228
-
229
- ## Model Card Contact
230
-
231
- [More Information Needed]
232
 
 
 
 
 
233
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ tags:
6
+ - gemma
7
+ - function calling
8
+ - on-device language model
9
+ - android
10
+ - conversational
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  ---
12
 
13
+ # Octopus V1: On-device language model for function calling of software APIs
14
+ <p align="center">
15
+ - <a href="https://www.nexa4ai.com/" target="_blank">Nexa AI Product</a>
16
+ - <a href="https://nexaai.github.io/octopus" target="_blank">ArXiv</a>
17
+ </p>
18
+
19
+ <p align="center" width="100%">
20
+ <a><img src="Octopus-logo.jpeg" alt="nexa-octopus" style="width: 40%; min-width: 300px; display: block; margin: auto;"></a>
21
+ </p>
22
+
23
+ ## Introducing Octopus-V2-2B
24
+ Octopus-V2-2B, an advanced open-source language model with 2 billion parameters, represents Nexa AI's research breakthrough in the application of large language models (LLMs) for function calling, specifically tailored for Android APIs. Unlike Retrieval-Augmented Generation (RAG) methods, which require detailed descriptions of potential function arguments—sometimes needing up to tens of thousands of input tokens—Octopus-V2-2B introduces a unique **functional token** strategy for both its training and inference stages. This approach not only allows it to achieve performance levels comparable to GPT-4 but also significantly enhances its inference speed beyond that of RAG-based methods, making it especially beneficial for edge computing devices.
25
+
26
+ 📱 **On-device Applications**: Octopus-V2-2B is engineered to operate seamlessly on Android devices, extending its utility across a wide range of applications, from Android system management to the orchestration of multiple devices. Further demonstrations of its capabilities are available on the [Nexa AI Research Page](https://nexaai.github.io/octopus), showcasing its adaptability and potential for on-device integration.
27
+
28
+ 🚀 **Inference Speed**: When benchmarked, Octopus-V2-2B demonstrates a remarkable inference speed, outperforming the combination of "Llama7B + RAG solution" by a factor of 36X on a single A100 GPU. Furthermore, compared to GPT-4-turbo (gpt-4-0125-preview), which relies on clusters A100/H100 GPUs, Octopus-V2-2B is 168% faster. This efficiency is attributed to our **functional token** design.
29
+
30
+ 🐙 **Accuracy**: Octopus-V2-2B not only excels in speed but also in accuracy, surpassing the "Llama7B + RAG solution" in function call accuracy by 31%. It achieves a function call accuracy comparable to GPT-4 and RAG + GPT-3.5, with scores ranging between 98% and 100% across benchmark datasets.
31
+
32
+ 💪 **Function Calling Capabilities**: Octopus-V2-2B is capable of generating individual, nested, and parallel function calls across a variety of complex scenarios.
33
+
34
+ ## Example Use Cases
35
+ <p align="center" width="100%">
36
+ <a><img src="tool-usage-compressed.png" alt="ondevice" style="width: 80%; min-width: 300px; display: block; margin: auto;"></a>
37
+ </p>
38
+
39
+ You can run the model on a GPU using the following code.
40
+ ```python
41
+ from gemma.modeling_gemma import GemmaForCausalLM
42
+ from transformers import AutoTokenizer
43
+ import torch
44
+ import time
45
+
46
+ def inference(input_text):
47
+ start_time = time.time()
48
+ input_ids = tokenizer(input_text, return_tensors="pt").to(model.device)
49
+ input_length = input_ids["input_ids"].shape[1]
50
+ outputs = model.generate(
51
+ input_ids=input_ids["input_ids"],
52
+ max_length=1024,
53
+ do_sample=False)
54
+ generated_sequence = outputs[:, input_length:].tolist()
55
+ res = tokenizer.decode(generated_sequence[0])
56
+ end_time = time.time()
57
+ return {"output": res, "latency": end_time - start_time}
58
+
59
+ model_id = "NexaAIDev/android_API_10k_data"
60
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
61
+ model = GemmaForCausalLM.from_pretrained(
62
+ model_id, torch_dtype=torch.bfloat16, device_map="auto"
63
+ )
64
+
65
+ input_text = "Take a selfie for me with front camera"
66
+ nexa_query = f"Below is the query from the users, please call the correct function and generate the parameters to call the function.\n\nQuery: {input_text} \n\nResponse:"
67
+ start_time = time.time()
68
+ print("nexa model result:\n", inference(nexa_query))
69
+ print("latency:", time.time() - start_time," s")
70
+ ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  ## Evaluation
73
+ <p align="center" width="100%">
74
+ <a><img src="latency_plot.jpg" alt="ondevice" style="width: 80%; min-width: 300px; display: block; margin: auto; margin-bottom: 20px;"></a>
75
+ <a><img src="accuracy_plot.jpg" alt="ondevice" style="width: 80%; min-width: 300px; display: block; margin: auto;"></a>
76
+ </p>
77
 
78
+ ## License
79
+ This model was trained on commercially viable data and is under the [Nexa AI community disclaimer](https://www.nexa4ai.com/disclaimer).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
 
81
 
82
+ ## References
83
+ We thank the Google Gemma team for their amazing models!
84
+ ```
85
+ @misc{gemma-2023-open-models,
86
+ author = {{Gemma Team, Google DeepMind}},
87
+ title = {Gemma: Open Models Based on Gemini Research and Technology},
88
+ url = {https://goo.gle/GemmaReport},
89
+ year = {2023},
90
+ }
91
+ ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
 
93
+ ## Citation
94
+ ```
95
+ @misc{TODO}
96
+ ```
97
 
98
+ ## Contact
99
+ Please [contact us](dev@nexa4ai.com) to reach out for any issues and comments!