Instructions to use NexaAI/octo-planner-2b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NexaAI/octo-planner-2b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NexaAI/octo-planner-2b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("NexaAI/octo-planner-2b") model = AutoModelForCausalLM.from_pretrained("NexaAI/octo-planner-2b", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NexaAI/octo-planner-2b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NexaAI/octo-planner-2b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NexaAI/octo-planner-2b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NexaAI/octo-planner-2b
- SGLang
How to use NexaAI/octo-planner-2b with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "NexaAI/octo-planner-2b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NexaAI/octo-planner-2b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "NexaAI/octo-planner-2b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NexaAI/octo-planner-2b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NexaAI/octo-planner-2b with Docker Model Runner:
docker model run hf.co/NexaAI/octo-planner-2b
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,66 +1,76 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: cc-by-nc-4.0
|
| 3 |
-
---
|
| 4 |
-
# Octo-planner: On-device Language Model for Planner-Action Agents Framework
|
| 5 |
-
|
| 6 |
-
We're thrilled to introduce the Octo-planner, the latest breakthrough in on-device language models from Nexa AI. Developed for the Planner-Action Agents Framework, Octo-planner enables rapid and efficient planning without the need for cloud connectivity, this model together with [Octopus-V2](https://huggingface.co/NexaAIDev/Octopus-v2) can work on edge devices locally to support AI Agent usages.
|
| 7 |
-
|
| 8 |
-
### Key Features of Octo-planner:
|
| 9 |
-
- **Efficient Planning**: Utilizes fine-tuned plan model based on Gemma-2b (2.51 billion parameters) for high efficiency and low power consumption.
|
| 10 |
-
- **Agent Framework**: Separates planning and action, allowing for specialized optimization and improved scalability.
|
| 11 |
-
- **Enhanced Accuracy**: Achieves a planning success rate of 98.1% on benchmark dataset, providing reliable and effective performance.
|
| 12 |
-
- **On-device Operation**: Designed for edge devices, ensuring fast response times and enhanced privacy by processing data locally.
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
## Example Usage
|
| 16 |
-
Below is a demo of Octo-planner:
|
| 17 |
-
<p align="center" width="100%">
|
| 18 |
-
<a><img src="1-demo.png" alt="ondevice" style="width: 80%; min-width: 300px; display: block; margin: auto;"></a>
|
| 19 |
-
</p>
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
Run below code to use Octopus Planner for a given question:
|
| 23 |
-
```python
|
| 24 |
-
import torch
|
| 25 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 26 |
-
model_id = "NexaAIDev/octo-planner-2b"
|
| 27 |
-
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", torch_dtype=torch.bfloat16, trust_remote_code=True)
|
| 28 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 29 |
-
question = "Find my presentation for tomorrow's meeting, connect to the conference room projector via Bluetooth, increase the screen brightness, take a screenshot of the final summary slide, and email it to all participants"
|
| 30 |
-
inputs = f"<|user|>{question}<|end|><|assistant|>"
|
| 31 |
-
input_ids = tokenizer(inputs, return_tensors="pt").to(model.device)
|
| 32 |
-
outputs = model.generate(
|
| 33 |
-
input_ids=input_ids["input_ids"],
|
| 34 |
-
max_length=1024,
|
| 35 |
-
do_sample=False)
|
| 36 |
-
res = tokenizer.decode(outputs.tolist()[0])
|
| 37 |
-
print(f"=== inference result ===\n{res}")
|
| 38 |
-
```
|
| 39 |
-
|
| 40 |
-
## Training Data
|
| 41 |
-
We wrote 10 Android API descriptions to used to train the models, see this file for details. Below is one Android API description example
|
| 42 |
-
```
|
| 43 |
-
def send_email(recipient, title, content):
|
| 44 |
-
"""
|
| 45 |
-
Sends an email to a specified recipient with a given title and content.
|
| 46 |
-
Parameters:
|
| 47 |
-
- recipient (str): The email address of the recipient.
|
| 48 |
-
- title (str): The subject line of the email. This is a brief summary or title of the email's purpose or content.
|
| 49 |
-
- content (str): The main body text of the email. It contains the primary message, information, or content that is intended to be communicated to the recipient.
|
| 50 |
-
"""
|
| 51 |
-
```
|
| 52 |
-
|
| 53 |
-
## Contact Us
|
| 54 |
-
For support or to provide feedback, please [contact us](mailto:octopus@nexa4ai.com).
|
| 55 |
-
|
| 56 |
-
## License and Citation
|
| 57 |
-
Refer to our [license page](https://www.nexa4ai.com/licenses/v2) for usage details. Please cite our work using the below reference for any academic or research purposes.
|
| 58 |
-
```
|
| 59 |
-
@article{chen2024octoplannerondevicelanguagemodel,
|
| 60 |
-
title={Octo-planner: On-device Language Model for Planner-Action Agents},
|
| 61 |
-
author={Wei Chen and Zhiyuan Li and Zhen Guo and Yikang Shen},
|
| 62 |
-
year={2024},
|
| 63 |
-
eprint={2406.18082},
|
| 64 |
-
url={https://arxiv.org/abs/2406.18082},
|
| 65 |
-
}
|
| 66 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-nc-4.0
|
| 3 |
+
---
|
| 4 |
+
# Octo-planner: On-device Language Model for Planner-Action Agents Framework
|
| 5 |
+
|
| 6 |
+
We're thrilled to introduce the Octo-planner, the latest breakthrough in on-device language models from Nexa AI. Developed for the Planner-Action Agents Framework, Octo-planner enables rapid and efficient planning without the need for cloud connectivity, this model together with [Octopus-V2](https://huggingface.co/NexaAIDev/Octopus-v2) can work on edge devices locally to support AI Agent usages.
|
| 7 |
+
|
| 8 |
+
### Key Features of Octo-planner:
|
| 9 |
+
- **Efficient Planning**: Utilizes fine-tuned plan model based on Gemma-2b (2.51 billion parameters) for high efficiency and low power consumption.
|
| 10 |
+
- **Agent Framework**: Separates planning and action, allowing for specialized optimization and improved scalability.
|
| 11 |
+
- **Enhanced Accuracy**: Achieves a planning success rate of 98.1% on benchmark dataset, providing reliable and effective performance.
|
| 12 |
+
- **On-device Operation**: Designed for edge devices, ensuring fast response times and enhanced privacy by processing data locally.
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
## Example Usage
|
| 16 |
+
Below is a demo of Octo-planner:
|
| 17 |
+
<p align="center" width="100%">
|
| 18 |
+
<a><img src="1-demo.png" alt="ondevice" style="width: 80%; min-width: 300px; display: block; margin: auto;"></a>
|
| 19 |
+
</p>
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
Run below code to use Octopus Planner for a given question:
|
| 23 |
+
```python
|
| 24 |
+
import torch
|
| 25 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 26 |
+
model_id = "NexaAIDev/octo-planner-2b"
|
| 27 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", torch_dtype=torch.bfloat16, trust_remote_code=True)
|
| 28 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 29 |
+
question = "Find my presentation for tomorrow's meeting, connect to the conference room projector via Bluetooth, increase the screen brightness, take a screenshot of the final summary slide, and email it to all participants"
|
| 30 |
+
inputs = f"<|user|>{question}<|end|><|assistant|>"
|
| 31 |
+
input_ids = tokenizer(inputs, return_tensors="pt").to(model.device)
|
| 32 |
+
outputs = model.generate(
|
| 33 |
+
input_ids=input_ids["input_ids"],
|
| 34 |
+
max_length=1024,
|
| 35 |
+
do_sample=False)
|
| 36 |
+
res = tokenizer.decode(outputs.tolist()[0])
|
| 37 |
+
print(f"=== inference result ===\n{res}")
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
## Training Data
|
| 41 |
+
We wrote 10 Android API descriptions to used to train the models, see this file for details. Below is one Android API description example
|
| 42 |
+
```
|
| 43 |
+
def send_email(recipient, title, content):
|
| 44 |
+
"""
|
| 45 |
+
Sends an email to a specified recipient with a given title and content.
|
| 46 |
+
Parameters:
|
| 47 |
+
- recipient (str): The email address of the recipient.
|
| 48 |
+
- title (str): The subject line of the email. This is a brief summary or title of the email's purpose or content.
|
| 49 |
+
- content (str): The main body text of the email. It contains the primary message, information, or content that is intended to be communicated to the recipient.
|
| 50 |
+
"""
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
## Contact Us
|
| 54 |
+
For support or to provide feedback, please [contact us](mailto:octopus@nexa4ai.com).
|
| 55 |
+
|
| 56 |
+
## License and Citation
|
| 57 |
+
Refer to our [license page](https://www.nexa4ai.com/licenses/v2) for usage details. Please cite our work using the below reference for any academic or research purposes.
|
| 58 |
+
```
|
| 59 |
+
@article{chen2024octoplannerondevicelanguagemodel,
|
| 60 |
+
title={Octo-planner: On-device Language Model for Planner-Action Agents},
|
| 61 |
+
author={Wei Chen and Zhiyuan Li and Zhen Guo and Yikang Shen},
|
| 62 |
+
year={2024},
|
| 63 |
+
eprint={2406.18082},
|
| 64 |
+
url={https://arxiv.org/abs/2406.18082},
|
| 65 |
+
}
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
We thank the Google Gemma team for their amazing models!
|
| 69 |
+
```
|
| 70 |
+
@misc{gemma-2023-open-models,
|
| 71 |
+
author = {{Gemma Team, Google DeepMind}},
|
| 72 |
+
title = {Gemma: Open Models Based on Gemini Research and Technology},
|
| 73 |
+
url = {https://goo.gle/GemmaReport},
|
| 74 |
+
year = {2023},
|
| 75 |
+
}
|
| 76 |
+
```
|