Instructions to use Nanbeige/Nanbeige4.2-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Nanbeige/Nanbeige4.2-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Nanbeige/Nanbeige4.2-3B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Nanbeige/Nanbeige4.2-3B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Nanbeige/Nanbeige4.2-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Nanbeige/Nanbeige4.2-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.2-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Nanbeige/Nanbeige4.2-3B
- SGLang
How to use Nanbeige/Nanbeige4.2-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.2-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.2-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.2-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.2-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Nanbeige/Nanbeige4.2-3B with Docker Model Runner:
docker model run hf.co/Nanbeige/Nanbeige4.2-3B
"Weimplify is asked:"
Whether I use a GGUF or the BF16 from here using sglang, I always see the reasoning start with "Weimplify is asked: [...]".
{
"model": "Nanbeige4.2-3B_sgl",
"messages": [
{
"role": "user",
"content": "Reverse this string: '.DefaultCellStyle'"
}
],
"stream": true,
"temperature": 2,
"max_tokens": 4096
}
Weimplify is asked: "Reverse this string: '.DefaultCellStyle'". This is a straightforward question: reverse the given string literal. We need to output the reversed version of the string '.DefaultCellStyle'. Let's confirm: The string is literally characters: '.' then 'D', 'e', 'f', 'a', '
data: {"id":"2e8ac11a22654f71b544f7772bb3fb17","object":"chat.completion.chunk","created":1784686547,"model":"Nanbeige4.2-3B_sgl","choices":[{"index":0,"delta":{"reasoning_content":null,"role":"assistant","content":""},"logprobs":null,"finish_reason":null,"matched_stop":null}]}
data: {"id":"2e8ac11a22654f71b544f7772bb3fb17","object":"chat.completion.chunk","created":1784686547,"model":"Nanbeige4.2-3B_sgl","choices":[{"index":0,"delta":{"reasoning_content":"We"},"logprobs":null,"finish_reason":null,"matched_stop":null}]}
data: {"id":"2e8ac11a22654f71b544f7772bb3fb17","object":"chat.completion.chunk","created":1784686547,"model":"Nanbeige4.2-3B_sgl","choices":[{"index":0,"delta":{"reasoning_content":"impl"},"logprobs":null,"finish_reason":null,"matched_stop":null}]}
data: {"id":"2e8ac11a22654f71b544f7772bb3fb17","object":"chat.completion.chunk","created":1784686547,"model":"Nanbeige4.2-3B_sgl","choices":[{"index":0,"delta":{"reasoning_content":"ify"},"logprobs":null,"finish_reason":null,"matched_stop":null}]}
data: {"id":"2e8ac11a22654f71b544f7772bb3fb17","object":"chat.completion.chunk","created":1784686547,"model":"Nanbeige4.2-3B_sgl","choices":[{"index":0,"delta":{"reasoning_content":" is"},"logprobs":null,"finish_reason":null,"matched_stop":null}]}
data: {"id":"2e8ac11a22654f71b544f7772bb3fb17","object":"chat.completion.chunk","created":1784686547,"model":"Nanbeige4.2-3B_sgl","choices":[{"index":0,"delta":{"reasoning_content":" asked"},"logprobs":null,"finish_reason":null,"matched_stop":null}]}
data: {"id":"2e8ac11a22654f71b544f7772bb3fb17","object":"chat.completion.chunk","created":1784686547,"model":"Nanbeige4.2-3B_sgl","choices":[{"index":0,"delta":{"reasoning_content":":"},"logprobs":null,"finish_reason":null,"matched_stop":null}]}
I don't know what's going on
Nevermind, it seems it was specific to this exact user prompt! It definitely breaks models 😂 but not right at start usually!
Edit: nope, it actually also happens with Draw a lizard in ASCII art. for example, but doesn't with a simple hey
Thanks for reporting this and for providing the reproduction details. In this version, our SFT data cleaning and filtering, as well as the RL rewards, focus primarily on the quality of the final content, so some artifacts in the reasoning trace can still slip through. Improvements targeting the quality of the reasoning traces will be included in future versions.
BTW, for normal use, we recommend temperature=0.6. A temperature of 2.0 is well above our recommended setting and can make this kind of unstable behavior more likely.
Oh no sorry, was a wrong copy paste! of course temp was much lower! It's just that at some point I wanted to go extreme by curiosity. Temp was about 0.6-1.0 in my tests.
Understood, thanks for the clarification :)