RichardErkhov commited on
Commit
98a9645
·
verified ·
1 Parent(s): e530595

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +184 -0
README.md ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ octo-net - AWQ
11
+ - Model creator: https://huggingface.co/NexaAIDev/
12
+ - Original model: https://huggingface.co/NexaAIDev/octo-net/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ license: cc-by-nc-4.0
20
+ base_model: microsoft/Phi-3
21
+ model-index:
22
+ - name: Octopus-V4-3B
23
+ results: []
24
+ tags:
25
+ - AI agent
26
+ - Graph
27
+ inference: false
28
+ space: false
29
+ spaces: false
30
+ language:
31
+ - en
32
+ ---
33
+ # Octopus V4: Graph of language models
34
+
35
+ ## Octopus V4
36
+ <p align="center">
37
+ - <a href="https://www.nexa4ai.com/" target="_blank">Nexa AI Website</a>
38
+ - <a href="https://github.com/NexaAI/octopus-v4" target="_blank">Octopus-v4 Github</a>
39
+ - <a href="https://arxiv.org/abs/2404.19296" target="_blank">ArXiv</a>
40
+ - <a href="https://huggingface.co/spaces/NexaAIDev/domain_llm_leaderboard" target="_blank">Domain LLM Leaderbaord</a>
41
+ - <a href="https://graph.nexa4ai.com/" target="_blank">Graph demo</a>
42
+ </p>
43
+
44
+ <p align="center" width="100%">
45
+ <a><img src="octopus-v4-logo.png" alt="nexa-octopus" style="width: 40%; min-width: 300px; display: block; margin: auto;"></a>
46
+ </p>
47
+
48
+ ## Quantized Octopus V4
49
+ To run the model on-device, we have prepared [quantized models](https://huggingface.co/NexaAIDev/octopus-v4-gguf) in gguf format for you.
50
+
51
+ ## Introduction
52
+
53
+ 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.
54
+
55
+ 📱 **Compact Size**: Octopus-V4-3B is compact, enabling it to operate on smart devices efficiently and swiftly.
56
+
57
+ 🐙 **Accuracy**: Octopus-V4-3B accurately maps user queries to the specialized model using a functional token design, enhancing its precision.
58
+
59
+ 💪 **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.
60
+
61
+ ## Example Use Cases
62
+
63
+ ```text
64
+ Query: Tell me the result of derivative of x^3 when x is 2?
65
+
66
+ # <nexa_4> represents the math gpt.
67
+ Response: <nexa_4> ('Determine the derivative of the function f(x) = x^3 at the point where x equals 2, and interpret the result within the context of rate of change and tangent slope.')<nexa_end>
68
+ ```
69
+
70
+ You can run the model on a GPU using the following code.
71
+ ```python
72
+ import torch
73
+ from transformers import AutoModelForCausalLM, AutoTokenizer
74
+ import time
75
+ torch.random.manual_seed(0)
76
+
77
+ model = AutoModelForCausalLM.from_pretrained(
78
+ "NexaAIDev/Octopus-v4",
79
+ device_map="cuda:0",
80
+ torch_dtype=torch.bfloat16,
81
+ trust_remote_code=True
82
+ )
83
+ tokenizer = AutoTokenizer.from_pretrained("NexaAIDev/Octopus-v4")
84
+
85
+ question = "Tell me the result of derivative of x^3 when x is 2?"
86
+
87
+ 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|>"
88
+
89
+ print('\n============= Below is the response ==============\n')
90
+
91
+ # You should consider to use early stopping with <nexa_end> token to accelerate
92
+ input_ids = tokenizer(inputs, return_tensors="pt")['input_ids'].to(model.device)
93
+
94
+ generated_token_ids = []
95
+ start = time.time()
96
+
97
+ # set a large enough number here to avoid insufficient length
98
+ for i in range(200):
99
+ next_token = model(input_ids).logits[:, -1].argmax(-1)
100
+ generated_token_ids.append(next_token.item())
101
+
102
+ input_ids = torch.cat([input_ids, next_token.unsqueeze(1)], dim=-1)
103
+
104
+ # 32041 is the token id of <nexa_end>
105
+ if next_token.item() == 32041:
106
+ break
107
+
108
+ print(tokenizer.decode(generated_token_ids))
109
+ end = time.time()
110
+ print(f'Elapsed time: {end - start:.2f}s')
111
+ ```
112
+
113
+
114
+
115
+ ## License
116
+ This model was trained on commercially viable data. For use of our model, refer to the [license information](https://www.nexa4ai.com/licenses/licenses-v4).
117
+
118
+
119
+ ## Performance
120
+ ### Model Selection
121
+ We leverage the latest Language Large Models for a variety of domains. Below is a summary of the chosen models for each category. In cases where no specialized model exists for a subject, we utilize generic models like Llama3-8b.
122
+
123
+
124
+ | **Model** | **Category** | **Subjects** |
125
+ |-----------------------------------------|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
126
+ | `jondurbin/bagel-8b-v1.0` | Biology | `college_biology`, `high_school_biology` |
127
+ | `Weyaxi/Einstein-v6.1-Llama3-8B` | Physics | `astronomy`, `college_physics`, `conceptual_physics`, `high_school_physics` |
128
+ | `meta-llama/Meta-Llama-3-8B-Instruct` | Business | `business_ethics`, `management`, `marketing` |
129
+ | `meta-llama/Meta-Llama-3-8B-Instruct` | Chemistry | `college_chemistry`, `high_school_chemistry` |
130
+ | `abacusai/Llama-3-Smaug-8B` | Computer Science | `college_computer_science`, `computer_security`, `high_school_computer_science`, `machine_learning` |
131
+ | `Open-Orca/Mistral-7B-OpenOrca` | Math | `abstract_algebra`, `college_mathematics`, `elementary_mathematics`, `high_school_mathematics`, `high_school_statistics` |
132
+ | `meta-llama/Meta-Llama-3-8B-Instruct` | Economics | `econometrics`, `high_school_macroeconomics`, `high_school_microeconomics` |
133
+ | `AdaptLLM/medicine-chat` | Health | `anatomy`, `clinical_knowledge`, `college_medicine`, `human_aging`, `medical_genetics`, `nutrition`, `professional_medicine`, `virology` |
134
+ | `STEM-AI-mtl/phi-2-electrical-engineering` | Engineering | `electrical_engineering` |
135
+ | `meta-llama/Meta-Llama-3-8B-Instruct` | Philosophy | `formal_logic`, `logical_fallacies`, `moral_disputes`, `moral_scenarios`, `philosophy`, `world_religions` |
136
+ | `microsoft/Phi-3-mini-128k-instruct` | Other | `global_facts`, `miscellaneous`, `professional_accounting` |
137
+ | `meta-llama/Meta-Llama-3-8B-Instruct` | History | `high_school_european_history`, `high_school_us_history`, `high_school_world_history`, `prehistory` |
138
+ | `meta-llama/Meta-Llama-3-8B-Instruct` | Culture | `human_sexuality`, `sociology` |
139
+ | `AdaptLLM/law-chat` | Law | `international_law`, `jurisprudence`, `professional_law` |
140
+ | `meta-llama/Meta-Llama-3-8B-Instruct` | Psychology | `high_school_psychology`, `professional_psychology` |
141
+
142
+
143
+ ### MMLU Benchmark Results (5-shot learning)
144
+ Here are the comparative MMLU scores for various models tested under a 5-shot learning setup:
145
+
146
+ | **Model** | **MMLU Score** |
147
+ |-----------------------------------|----------------|
148
+ | Octopus-V4 | **74.8%** |
149
+ | GPT-3.5 | 70.0% |
150
+ | Phi-3-mini-128k-instruct | 68.1% |
151
+ | OpenELM-3B | 26.7% |
152
+ | Lamma3-8b-instruct | 68.4% |
153
+ | Gemma-2b | 42.3% |
154
+ | Gemma-7b | 64.3% |
155
+
156
+ ### Domain LLM Leaderboard
157
+ Explore our collection of domain-specific large language models (LLMs) or contribute by suggesting new models tailored to specific domains. For detailed information on available models and to engage with our community, please visit our [Domain LLM Leaderboard](https://huggingface.co/spaces/NexaAIDev/domain_llm_leaderboard).
158
+
159
+ ## References
160
+ We thank the Microsoft team for their amazing model!
161
+ ```
162
+ @article{abdin2024phi,
163
+ title={Phi-3 Technical Report: A Highly Capable Language Model Locally on Your Phone},
164
+ 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},
165
+ journal={arXiv preprint arXiv:2404.14219},
166
+ year={2024}
167
+ }
168
+ ```
169
+
170
+ ## Citation
171
+ ```
172
+ @misc{chen2024octopus,
173
+ title={Octopus v4: Graph of language models},
174
+ author={Wei Chen and Zhiyuan Li},
175
+ year={2024},
176
+ eprint={2404.19296},
177
+ archivePrefix={arXiv},
178
+ primaryClass={cs.CL}
179
+ }
180
+ ```
181
+
182
+ ## Contact
183
+ Please [contact us](mailto:[email protected]) to reach out for any issues and comments!
184
+