Instructions to use nex-agi/Nex-N2-Pro with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nex-agi/Nex-N2-Pro with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nex-agi/Nex-N2-Pro") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("nex-agi/Nex-N2-Pro") model = AutoModelForImageTextToText.from_pretrained("nex-agi/Nex-N2-Pro") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nex-agi/Nex-N2-Pro with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nex-agi/Nex-N2-Pro" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nex-agi/Nex-N2-Pro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nex-agi/Nex-N2-Pro
- SGLang
How to use nex-agi/Nex-N2-Pro 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 "nex-agi/Nex-N2-Pro" \ --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": "nex-agi/Nex-N2-Pro", "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 "nex-agi/Nex-N2-Pro" \ --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": "nex-agi/Nex-N2-Pro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nex-agi/Nex-N2-Pro with Docker Model Runner:
docker model run hf.co/nex-agi/Nex-N2-Pro
Update README.md
Browse files
README.md
CHANGED
|
@@ -122,6 +122,49 @@ python -m sglang.launch_server \
|
|
| 122 |
--mamba-scheduler-strategy extra_buffer
|
| 123 |
```
|
| 124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
### Recommended Sampling Parameters
|
| 126 |
|
| 127 |
For the best generation quality, we recommend the following sampling parameters:
|
|
|
|
| 122 |
--mamba-scheduler-strategy extra_buffer
|
| 123 |
```
|
| 124 |
|
| 125 |
+
### Docker Deployment
|
| 126 |
+
|
| 127 |
+
We also provide a prebuilt Docker image with our customized `sglang` fork preinstalled: **`nexagi/sglang:v0.5.12`**. The launch command is the same as above.
|
| 128 |
+
|
| 129 |
+
#### Nex-N2-Pro
|
| 130 |
+
|
| 131 |
+
```bash
|
| 132 |
+
# Multi-node (2 nodes). Run the same command on every node with:
|
| 133 |
+
# <node-rank> = 0 on the head node, 1 on the other node
|
| 134 |
+
# <node0-ip> = IP of the head node (reachable from all others)
|
| 135 |
+
docker run --gpus all --shm-size 32g --network host \
|
| 136 |
+
-v /path/to/your/model:/model \
|
| 137 |
+
nexagi/sglang:v0.5.12 \
|
| 138 |
+
python3 -m sglang.launch_server \
|
| 139 |
+
--model-path /model \
|
| 140 |
+
--tp 16 \
|
| 141 |
+
--nnodes 2 \
|
| 142 |
+
--node-rank <node-rank> \
|
| 143 |
+
--dist-init-addr <node0-ip>:20000 \
|
| 144 |
+
--host 0.0.0.0 --port 30000 \
|
| 145 |
+
--reasoning-parser qwen3 \
|
| 146 |
+
--tool-call-parser qwen3_coder \
|
| 147 |
+
--mamba-scheduler-strategy extra_buffer
|
| 148 |
+
```
|
| 149 |
+
|
| 150 |
+
#### Nex-N2-mini
|
| 151 |
+
|
| 152 |
+
Single node with 2× H100:
|
| 153 |
+
|
| 154 |
+
```bash
|
| 155 |
+
docker run --gpus all --shm-size 32g --ipc=host \
|
| 156 |
+
-p 30000:30000 \
|
| 157 |
+
-v /path/to/your/model:/model \
|
| 158 |
+
nexagi/sglang:v0.5.12 \
|
| 159 |
+
python3 -m sglang.launch_server \
|
| 160 |
+
--model-path /model \
|
| 161 |
+
--tp 2 \
|
| 162 |
+
--host 0.0.0.0 --port 30000 \
|
| 163 |
+
--reasoning-parser qwen3 \
|
| 164 |
+
--tool-call-parser qwen3_coder \
|
| 165 |
+
--mamba-scheduler-strategy extra_buffer
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
### Recommended Sampling Parameters
|
| 169 |
|
| 170 |
For the best generation quality, we recommend the following sampling parameters:
|