Instructions to use nex-agi/Nex-N2-mini with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nex-agi/Nex-N2-mini with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nex-agi/Nex-N2-mini") 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, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("nex-agi/Nex-N2-mini") model = AutoModelForMultimodalLM.from_pretrained("nex-agi/Nex-N2-mini") 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-mini 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-mini" # 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-mini", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nex-agi/Nex-N2-mini
- SGLang
How to use nex-agi/Nex-N2-mini 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-mini" \ --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-mini", "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-mini" \ --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-mini", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nex-agi/Nex-N2-mini with Docker Model Runner:
docker model run hf.co/nex-agi/Nex-N2-mini
File size: 1,326 Bytes
271699a | 1 2 3 4 5 6 7 8 | <svg width="1118" height="354" viewBox="0 0 1118 354" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1000.47 204.517L977.244 175.437L949.704 141L949.165 141.652L906.805 194.625L884.304 222.799L883.792 223.451L883.765 223.479L861.237 251.652L846.66 233.399L823.404 204.319L780.559 257.944L758.031 286.117L705 352.468H835.745L845.932 339.741L888.777 286.117L911.305 257.944L911.332 257.916L934.56 286.996L949.139 305.248L986.891 352.468H1117.64C1094.98 323.813 1044.55 260.048 1015.08 222.771L1000.47 204.517Z" fill="black"/>
<path d="M845.932 176.379L869.16 205.459L869.187 205.431L869.727 204.779L892.227 176.605L934.56 123.632L935.099 122.98L957.627 94.808L972.205 113.06L999.744 147.525L1093.41 30.3267L1106.48 13.9454L1117.64 3.25913e-05H986.891L934.372 65.728L911.871 93.872L911.332 94.552L838.845 3.8827L835.747 3.25913e-05H705L845.959 176.351L845.932 176.379Z" fill="black"/>
<path d="M501.499 261.748V221.813H752.03V130.86H501.499V90.9534H751.6L678.9 0H415L415.027 352.701H678.9L751.6 261.748H501.499Z" fill="black"/>
<path d="M281.67 249.173L135.396 153.907V266.272L268.634 353.041H394.921V352.7H394.927V3.05176e-05H281.67V249.173Z" fill="black"/>
<path d="M113.257 103.868L259.532 199.135V86.7694L126.293 3.05176e-05L0.00665283 3.05176e-05V0.34137H0V353.041H113.257L113.257 103.868Z" fill="black"/>
</svg>
|