alexchen4ai
commited on
Commit
•
cf6f587
1
Parent(s):
be9aea4
Update README.md
Browse files
README.md
CHANGED
@@ -1,199 +1,124 @@
|
|
1 |
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
|
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
|
|
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
12 |
-
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
19 |
|
20 |
-
- **Developed by:** [More Information Needed]
|
21 |
-
- **Funded by [optional]:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
|
|
|
|
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
- **Repository:** [More Information Needed]
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
39 |
|
40 |
-
### Direct Use
|
41 |
|
42 |
-
|
43 |
|
44 |
-
|
45 |
|
46 |
-
|
|
|
47 |
|
48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
49 |
|
50 |
-
|
|
|
51 |
|
52 |
-
|
|
|
53 |
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
-
|
|
|
|
|
|
|
57 |
|
58 |
-
## Bias, Risks, and Limitations
|
59 |
|
60 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
61 |
|
62 |
-
|
|
|
63 |
|
64 |
-
### Recommendations
|
65 |
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
##
|
71 |
-
|
72 |
-
Use the code below to get started with the model.
|
73 |
-
|
74 |
-
[More Information Needed]
|
75 |
-
|
76 |
-
## Training Details
|
77 |
-
|
78 |
-
### Training Data
|
79 |
-
|
80 |
-
<!-- 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. -->
|
81 |
-
|
82 |
-
[More Information Needed]
|
83 |
-
|
84 |
-
### Training Procedure
|
85 |
-
|
86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
87 |
-
|
88 |
-
#### Preprocessing [optional]
|
89 |
-
|
90 |
-
[More Information Needed]
|
91 |
-
|
92 |
-
|
93 |
-
#### Training Hyperparameters
|
94 |
-
|
95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
96 |
-
|
97 |
-
#### Speeds, Sizes, Times [optional]
|
98 |
-
|
99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
100 |
-
|
101 |
-
[More Information Needed]
|
102 |
-
|
103 |
-
## Evaluation
|
104 |
-
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
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).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
-
|
199 |
-
[More Information Needed]
|
|
|
1 |
---
|
2 |
+
license: cc-by-nc-4.0
|
3 |
+
base_model: microsoft/Phi-3
|
4 |
+
model-index:
|
5 |
+
- name: Octopus-V4-3B
|
6 |
+
results: []
|
7 |
+
tags:
|
8 |
+
- AI agent
|
9 |
+
- Graph
|
10 |
+
inference: false
|
11 |
+
space: false
|
12 |
+
spaces: false
|
13 |
+
language:
|
14 |
+
- en
|
15 |
---
|
16 |
+
# Octopus V4: Graph of language models
|
17 |
|
18 |
+
## Octopus V4
|
19 |
+
<p align="center">
|
20 |
+
- <a href="https://www.nexa4ai.com/" target="_blank">Nexa AI Website</a>
|
21 |
+
- <a href="https://www.nexa4ai.com/" target="_blank">Octopus-v4 Github</a>
|
22 |
+
- <a href="https://arxiv.org/abs/2404.01744" target="_blank">ArXiv</a>
|
23 |
+
</p>
|
24 |
|
25 |
+
<p align="center" width="100%">
|
26 |
+
<a><img src="octopus-v4-logo.png" alt="nexa-octopus" style="width: 40%; min-width: 300px; display: block; margin: auto;"></a>
|
27 |
+
</p>
|
28 |
|
29 |
+
## Introduction
|
30 |
|
31 |
+
Octopus-V4-3B, an advanced open-source language model with 3 billion parameters, serves as the master node in Nexa AI's envisioned graph of language models. Tailored specifically for the MMLU benchmark topics, this model efficiently translates user queries into formats that specialized models can effectively process. It excels at directing these queries to the appropriate specialized model, ensuring precise and effective query handling.
|
32 |
|
33 |
+
📱 **Compact Size**: Octopus-V4-3B is compact, enabling it to operate on smart devices efficiently and swiftly.
|
34 |
|
35 |
+
🐙 **Accuracy**: Octopus-V4-3B accurately maps user queries to the specialized model using a functional token design, enhancing its precision.
|
36 |
|
37 |
+
💪 **Reformat Query**: Octopus-V4-3B assists in converting natural human language into a more professional format, improving query description and resulting in more accurate responses.
|
38 |
|
39 |
+
## Example Use Cases
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
<p align="center" width="100%">
|
43 |
+
<a><img src="tool-usage.png" alt="ondevice" style="width: 80%; min-width: 300px; display: block; margin: auto;"></a>
|
44 |
+
</p>
|
45 |
|
46 |
+
You can run the model on a GPU using the following code.
|
47 |
+
```python
|
48 |
+
import torch
|
49 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
50 |
+
import time
|
51 |
+
import warnings
|
52 |
+
warnings.filterwarnings("ignore")
|
53 |
+
torch.random.manual_seed(0)
|
54 |
+
import json
|
55 |
|
|
|
|
|
|
|
56 |
|
57 |
+
model = AutoModelForCausalLM.from_pretrained(
|
58 |
+
"NexaAIDev/Octopus-v4",
|
59 |
+
device_map="cuda:0",
|
60 |
+
torch_dtype=torch.bfloat16,
|
61 |
+
trust_remote_code=True
|
62 |
+
)
|
63 |
+
tokenizer = AutoTokenizer.from_pretrained("NexaAIDev/octopus-v4-finetuned-v1")
|
64 |
|
|
|
65 |
|
|
|
66 |
|
67 |
+
question = "Tell me the result of derivative of x^3 when x is 2?"
|
68 |
|
69 |
+
inputs = f"<|system|>You are a router. Below is the query from the users, please call the correct function and generate the parameters to call the function.<|end|><|user|>{question}<|end|><|assistant|>"
|
70 |
|
71 |
+
print(inputs)
|
72 |
+
print('\n============= Below is the response ==============\n')
|
73 |
|
|
|
74 |
|
75 |
+
# You should consider to use early stopping with <nexa_end> token to accelerate
|
76 |
+
input_ids = tokenizer(inputs, return_tensors="pt")['input_ids'].to(model.device)
|
77 |
|
78 |
+
generated_token_ids = []
|
79 |
+
start = time.time()
|
80 |
|
81 |
+
# set a large enough number here to avoid insufficient length
|
82 |
+
for i in range(200):
|
83 |
+
next_token = model(input_ids).logits[:, -1].argmax(-1)
|
84 |
+
generated_token_ids.append(next_token.item())
|
85 |
+
input_ids = torch.cat([input_ids, next_token.unsqueeze(1)], dim=-1)
|
86 |
+
if "<nexa_end>" in tokenizer.decode(generated_token_ids):
|
87 |
+
break
|
88 |
|
89 |
+
print(tokenizer.decode(generated_token_ids))
|
90 |
+
end = time.time()
|
91 |
+
print(f'Elapsed time: {end - start:.2f}s')
|
92 |
+
```
|
93 |
|
|
|
94 |
|
|
|
95 |
|
96 |
+
## License
|
97 |
+
This model was trained on commercially viable data. For use of our model, refer to the [license information](https://www.nexa4ai.com/licenses).
|
98 |
|
|
|
99 |
|
100 |
+
## References
|
101 |
+
We thank the Microsoft team for their amazing model!
|
102 |
+
```
|
103 |
+
@article{abdin2024phi,
|
104 |
+
title={Phi-3 Technical Report: A Highly Capable Language Model Locally on Your Phone},
|
105 |
+
author={Abdin, Marah and Jacobs, Sam Ade and Awan, Ammar Ahmad and Aneja, Jyoti and Awadallah, Ahmed and Awadalla, Hany and Bach, Nguyen and Bahree, Amit and Bakhtiari, Arash and Behl, Harkirat and others},
|
106 |
+
journal={arXiv preprint arXiv:2404.14219},
|
107 |
+
year={2024}
|
108 |
+
}
|
109 |
+
```
|
110 |
|
111 |
+
## Citation
|
112 |
+
```
|
113 |
+
@misc{chen2024octopus,
|
114 |
+
title={Octopus v2: On-device language model for super agent},
|
115 |
+
author={Wei Chen and Zhiyuan Li},
|
116 |
+
year={2024},
|
117 |
+
eprint={2404.01744},
|
118 |
+
archivePrefix={arXiv},
|
119 |
+
primaryClass={cs.CL}
|
120 |
+
}
|
121 |
+
```
|
122 |
|
123 |
+
## Contact
|
124 |
+
Please [contact us](mailto:[email protected]) to reach out for any issues and comments!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|