Instructions to use Nanbeige/Nanbeige4.1-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Nanbeige/Nanbeige4.1-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Nanbeige/Nanbeige4.1-3B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Nanbeige/Nanbeige4.1-3B") model = AutoModelForCausalLM.from_pretrained("Nanbeige/Nanbeige4.1-3B") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Nanbeige/Nanbeige4.1-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Nanbeige/Nanbeige4.1-3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Nanbeige/Nanbeige4.1-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Nanbeige/Nanbeige4.1-3B
- SGLang
How to use Nanbeige/Nanbeige4.1-3B 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 "Nanbeige/Nanbeige4.1-3B" \ --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": "Nanbeige/Nanbeige4.1-3B", "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 "Nanbeige/Nanbeige4.1-3B" \ --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": "Nanbeige/Nanbeige4.1-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Nanbeige/Nanbeige4.1-3B with Docker Model Runner:
docker model run hf.co/Nanbeige/Nanbeige4.1-3B
Feature Request: TFLite Q4/Q6/Q8 Quantizations for Nanbeige4.1-3B
Motivation
Enable local inference on Android phones (Snapdragon 865+, 8GB RAM) via Google AI Edge Gallery / LiteRT runtime. This 3B SLM outperforms Qwen3-32B on benchmarks but lacks mobile-optimized formats.
Current Formats Available
- ✅ BF16 base model
- ✅ GGUF quants (Q4_K_M, Q6_K, Q8_0 via mradermacher repo) [web:33]
- ❌ No TFLite/LiteRT conversions
Requested Formats
- TFLite INT4 (Q4 equivalent) - ~1.5GB, target 4-6 tok/s on Adreno GPU
- TFLite INT6 (Q6 equivalent) - ~2.5GB, balanced quality/speed
- TFLite INT8 (Q8 equivalent) - ~3GB, highest fidelity
Conversion Path (for maintainers)
python
Using LiteRT Torch Generative API (recommended)
import ai_edge_torch
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("Nanbeige/Nanbeige4.1-3B")
Re-author + convert + quantize per Google docs
edge_model = ai_edge_torch.convert(model, backend="odml_torch")
edge_model.export("nanbeige4.1-3b-q4.tflite")
Target Deployments
- Google AI Edge Gallery (Play Store/GitHub)
- LiteRT-LM runtime w/ NNAPI/GPU delegates
- MediaPipe LLM Inference API
Benefits
- Democratizes access to top 3B SLM on midrange phones (Mi 10T Pro with 8gb ram, etc.)
- Complements GGUF ecosystem with mobile-native format
- Precedents: Gemma 2B, Phi-2 have official TFLite quants
support for Nanbeige 3b in LiteRT (before TFlite) is made here https://github.com/google-ai-edge/LiteRT/issues/6419
- please create TFlite Versions of this model
- check this link : https://github.com/google-ai-edge/LiteRT/issues/6419
- feel free to contribute - support this model in LiteRT inference engine
Thankyou