Views
No views yet
1Query: Tell me the result of derivative of x^3 when x is 2?
2
3# <nexa_4> represents the math gpt.
4Response: <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>1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3import time
4torch.random.manual_seed(0)
5
6model = AutoModelForCausalLM.from_pretrained(
7 "NexaAIDev/Octopus-v4",
8 device_map="cuda:0",
9 torch_dtype=torch.bfloat16,
10 trust_remote_code=True
11)
12tokenizer = AutoTokenizer.from_pretrained("NexaAIDev/Octopus-v4")
13
14question = "Tell me the result of derivative of x^3 when x is 2?"
15
16inputs = 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|>"
17
18print('\n============= Below is the response ==============\n')
19
20# You should consider to use early stopping with <nexa_end> token to accelerate
21input_ids = tokenizer(inputs, return_tensors="pt")['input_ids'].to(model.device)
22
23generated_token_ids = []
24start = time.time()
25
26# set a large enough number here to avoid insufficient length
27for i in range(200):
28 next_token = model(input_ids).logits[:, -1].argmax(-1)
29 generated_token_ids.append(next_token.item())
30
31 input_ids = torch.cat([input_ids, next_token.unsqueeze(1)], dim=-1)
32
33 # 32041 is the token id of <nexa_end>
34 if next_token.item() == 32041:
35 break
36
37print(tokenizer.decode(generated_token_ids))
38end = time.time()
39print(f'Elapsed time: {end - start:.2f}s')| Model | Category | Subjects |
|---|---|---|
jondurbin/bagel-8b-v1.0 | Biology | college_biology, high_school_biology |
Weyaxi/Einstein-v6.1-Llama3-8B | Physics | astronomy, college_physics, conceptual_physics, high_school_physics |
meta-llama/Meta-Llama-3-8B-Instruct | Business | business_ethics, management, marketing |
meta-llama/Meta-Llama-3-8B-Instruct | Chemistry | college_chemistry, high_school_chemistry |
abacusai/Llama-3-Smaug-8B | Computer Science | college_computer_science, computer_security, high_school_computer_science, machine_learning |
Open-Orca/Mistral-7B-OpenOrca | Math | abstract_algebra, college_mathematics, elementary_mathematics, high_school_mathematics, high_school_statistics |
meta-llama/Meta-Llama-3-8B-Instruct | Economics | econometrics, high_school_macroeconomics, high_school_microeconomics |
AdaptLLM/medicine-chat | Health | anatomy, clinical_knowledge, college_medicine, human_aging, medical_genetics, nutrition, professional_medicine, virology |
STEM-AI-mtl/phi-2-electrical-engineering | Engineering | electrical_engineering |
meta-llama/Meta-Llama-3-8B-Instruct | Philosophy | formal_logic, logical_fallacies, moral_disputes, moral_scenarios, philosophy, world_religions |
microsoft/Phi-3-mini-128k-instruct | Other | global_facts, miscellaneous, professional_accounting |
meta-llama/Meta-Llama-3-8B-Instruct | History | high_school_european_history, high_school_us_history, high_school_world_history, prehistory |
meta-llama/Meta-Llama-3-8B-Instruct | Culture | human_sexuality, sociology |
AdaptLLM/law-chat | Law | international_law, jurisprudence, professional_law |
meta-llama/Meta-Llama-3-8B-Instruct | Psychology | high_school_psychology, professional_psychology |
| Model | MMLU Score |
|---|---|
| Octopus-V4 | 74.8% |
| GPT-3.5 | 70.0% |
| Phi-3-mini-128k-instruct | 68.1% |
| OpenELM-3B | 26.7% |
| Lamma3-8b-instruct | 68.4% |
| Gemma-2b | 42.3% |
| Gemma-7b | 64.3% |
@article{abdin2024phi,
title={Phi-3 Technical Report: A Highly Capable Language Model Locally on Your Phone},
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},
journal={arXiv preprint arXiv:2404.14219},
year={2024}
}@misc{chen2024octopus,
title={Octopus v4: Graph of language models},
author={Wei Chen and Zhiyuan Li},
year={2024},
eprint={2404.19296},
archivePrefix={arXiv},
primaryClass={cs.CL}
}