Text Generation
Transformers
Safetensors
GGUF
English
gemma
function calling
on-device language model
android
conversational
text-generation-inference
4-bit precision
awq
Instructions to use NexaAI/Octopus-v2-gguf-awq with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NexaAI/Octopus-v2-gguf-awq with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NexaAI/Octopus-v2-gguf-awq") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("NexaAI/Octopus-v2-gguf-awq") model = AutoModelForCausalLM.from_pretrained("NexaAI/Octopus-v2-gguf-awq", 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
- llama.cpp
How to use NexaAI/Octopus-v2-gguf-awq with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf NexaAI/Octopus-v2-gguf-awq:Q4_K_M # Run inference directly in the terminal: llama cli -hf NexaAI/Octopus-v2-gguf-awq:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf NexaAI/Octopus-v2-gguf-awq:Q4_K_M # Run inference directly in the terminal: llama cli -hf NexaAI/Octopus-v2-gguf-awq:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf NexaAI/Octopus-v2-gguf-awq:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf NexaAI/Octopus-v2-gguf-awq:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf NexaAI/Octopus-v2-gguf-awq:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf NexaAI/Octopus-v2-gguf-awq:Q4_K_M
Use Docker
docker model run hf.co/NexaAI/Octopus-v2-gguf-awq:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use NexaAI/Octopus-v2-gguf-awq with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NexaAI/Octopus-v2-gguf-awq" # 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/Octopus-v2-gguf-awq", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NexaAI/Octopus-v2-gguf-awq:Q4_K_M
- SGLang
How to use NexaAI/Octopus-v2-gguf-awq 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/Octopus-v2-gguf-awq" \ --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/Octopus-v2-gguf-awq", "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/Octopus-v2-gguf-awq" \ --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/Octopus-v2-gguf-awq", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use NexaAI/Octopus-v2-gguf-awq with Ollama:
ollama run hf.co/NexaAI/Octopus-v2-gguf-awq:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use NexaAI/Octopus-v2-gguf-awq with Docker Model Runner:
docker model run hf.co/NexaAI/Octopus-v2-gguf-awq:Q4_K_M
- Lemonade
How to use NexaAI/Octopus-v2-gguf-awq with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull NexaAI/Octopus-v2-gguf-awq:Q4_K_M
Run and chat with the model
lemonade run user.Octopus-v2-gguf-awq-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Update README.md
Browse files
README.md
CHANGED
|
@@ -31,12 +31,37 @@ Run with [Ollama](https://github.com/ollama/ollama)
|
|
| 31 |
ollama run NexaAIDev/octopus-v2-Q4_K_M
|
| 32 |
```
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
```python
|
|
|
|
| 38 |
from awq import AutoAWQForCausalLM
|
| 39 |
-
from transformers import AutoTokenizer, GemmaForCausalLM
|
| 40 |
import torch
|
| 41 |
import time
|
| 42 |
import numpy as np
|
|
@@ -51,28 +76,25 @@ def inference(input_text):
|
|
| 51 |
start_time = time.time()
|
| 52 |
generation_output = model.generate(
|
| 53 |
tokens,
|
| 54 |
-
do_sample=
|
| 55 |
-
temperature=0
|
| 56 |
-
top_p=0.95,
|
| 57 |
-
top_k=40,
|
| 58 |
max_new_tokens=512
|
| 59 |
)
|
| 60 |
end_time = time.time()
|
|
|
|
|
|
|
| 61 |
|
| 62 |
-
res = tokenizer.decode(generation_output[0])
|
| 63 |
-
res = res.split(input_text)
|
| 64 |
latency = end_time - start_time
|
| 65 |
-
|
| 66 |
-
num_output_tokens = len(output_tokens)
|
| 67 |
throughput = num_output_tokens / latency
|
| 68 |
|
| 69 |
-
return {"output": res
|
| 70 |
-
|
| 71 |
|
| 72 |
-
model_id = "
|
|
|
|
|
|
|
| 73 |
model = AutoAWQForCausalLM.from_quantized(model_id, fuse_layers=True,
|
| 74 |
trust_remote_code=False, safetensors=True)
|
| 75 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=False)
|
| 76 |
|
| 77 |
prompts = ["Below is the query from the users, please call the correct function and generate the parameters to call the function.\n\nQuery: Can you take a photo using the back camera and save it to the default location? \n\nResponse:"]
|
| 78 |
|
|
|
|
| 31 |
ollama run NexaAIDev/octopus-v2-Q4_K_M
|
| 32 |
```
|
| 33 |
|
| 34 |
+
Input example:
|
| 35 |
+
|
| 36 |
+
```dash
|
| 37 |
+
"Below is the query from the users, please call the correct function and generate the parameters to call the function.\n\nQuery: Take a selfie for me with front camera \n\nResponse:"
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
Output function example:
|
| 41 |
+
|
| 42 |
+
```json
|
| 43 |
+
def get_trending_news(category=None, region='US', language='en', max_results=5):
|
| 44 |
+
"""
|
| 45 |
+
Fetches trending news articles based on category, region, and language.
|
| 46 |
+
|
| 47 |
+
Parameters:
|
| 48 |
+
- category (str, optional): News category to filter by, by default use None for all categories. Optional to provide.
|
| 49 |
+
- region (str, optional): ISO 3166-1 alpha-2 country code for region-specific news, by default, uses 'US'. Optional to provide.
|
| 50 |
+
- language (str, optional): ISO 639-1 language code for article language, by default uses 'en'. Optional to provide.
|
| 51 |
+
- max_results (int, optional): Maximum number of articles to return, by default, uses 5. Optional to provide.
|
| 52 |
+
|
| 53 |
+
Returns:
|
| 54 |
+
- list[str]: A list of strings, each representing an article. Each string contains the article's heading and URL.
|
| 55 |
+
"""
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
## AWQ Quantization
|
| 59 |
+
|
| 60 |
+
Input Python example:
|
| 61 |
|
| 62 |
```python
|
| 63 |
+
from transformers import AutoTokenizer
|
| 64 |
from awq import AutoAWQForCausalLM
|
|
|
|
| 65 |
import torch
|
| 66 |
import time
|
| 67 |
import numpy as np
|
|
|
|
| 76 |
start_time = time.time()
|
| 77 |
generation_output = model.generate(
|
| 78 |
tokens,
|
| 79 |
+
do_sample=False,
|
| 80 |
+
temperature=0,
|
|
|
|
|
|
|
| 81 |
max_new_tokens=512
|
| 82 |
)
|
| 83 |
end_time = time.time()
|
| 84 |
+
generated_sequence = generation_output[:, input_length:].tolist()
|
| 85 |
+
res = tokenizer.decode(generated_sequence[0])
|
| 86 |
|
|
|
|
|
|
|
| 87 |
latency = end_time - start_time
|
| 88 |
+
num_output_tokens = len(generated_sequence[0])
|
|
|
|
| 89 |
throughput = num_output_tokens / latency
|
| 90 |
|
| 91 |
+
return {"output": res, "latency": latency, "throughput": throughput}
|
|
|
|
| 92 |
|
| 93 |
+
model_id = "NexaAIDev/Octopus-v2-gguf-awq"
|
| 94 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id,
|
| 95 |
+
trust_remote_code=False)
|
| 96 |
model = AutoAWQForCausalLM.from_quantized(model_id, fuse_layers=True,
|
| 97 |
trust_remote_code=False, safetensors=True)
|
|
|
|
| 98 |
|
| 99 |
prompts = ["Below is the query from the users, please call the correct function and generate the parameters to call the function.\n\nQuery: Can you take a photo using the back camera and save it to the default location? \n\nResponse:"]
|
| 100 |
|