Instructions to use Nanbeige/Nanbeige4.2-3B-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Nanbeige/Nanbeige4.2-3B-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Nanbeige/Nanbeige4.2-3B-Base", 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-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Nanbeige/Nanbeige4.2-3B-Base 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-Base" # 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-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Nanbeige/Nanbeige4.2-3B-Base
- SGLang
How to use Nanbeige/Nanbeige4.2-3B-Base 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-Base" \ --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-Base", "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-Base" \ --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-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Nanbeige/Nanbeige4.2-3B-Base with Docker Model Runner:
docker model run hf.co/Nanbeige/Nanbeige4.2-3B-Base
Update README.md
Browse filesupload technical report
README.md
CHANGED
|
@@ -14,6 +14,10 @@ tags:
|
|
| 14 |
<img src="figures/nbg.png" width="220" alt="Nanbeige Logo">
|
| 15 |
</div>
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# <span id="Introduction">1. Introduction</span>
|
| 18 |
|
| 19 |
Nanbeige4.2-3B-Base is a new base model in the Nanbeige4 series, trained from scratch with improvements to both model architecture and training data. It delivers substantial gains over the previous generation and outperforms opensource base models of comparable scale, including Qwen3.5-4B and Gemma4-E4B, across a broad range of benchmarks. Key features include:
|
|
@@ -22,7 +26,7 @@ Nanbeige4.2-3B-Base is a new base model in the Nanbeige4 series, trained from sc
|
|
| 22 |
|
| 23 |
- **Enhanced Training Data Recipe**: Expands the total amount of training data from 23T to 28T tokens, with more aggressive upsampling of math, code, STEM, and Synthetic-QA data to strengthen reasoning and coding capabilities.
|
| 24 |
|
| 25 |
-
The accompanying `modeling_nanbeige.py` also includes our latest architectural improvements, including **LoopSplit**, **mHC with depth attention**, and **concatenated n-gram embeddings**. These features have been incorporated into Nanbeige4.5, whose training is underway for release later in 2026.
|
| 26 |
|
| 27 |
# <span id="Model-Performance">2. Model Performance</span>
|
| 28 |
|
|
|
|
| 14 |
<img src="figures/nbg.png" width="220" alt="Nanbeige Logo">
|
| 15 |
</div>
|
| 16 |
|
| 17 |
+
<p align="center">
|
| 18 |
+
<a href="https://huggingface.co/Nanbeige/Nanbeige4.2-3B/blob/main/Nanbeige42_report.pdf"><b>Technical Report</b>👁️</a>
|
| 19 |
+
</p>
|
| 20 |
+
|
| 21 |
# <span id="Introduction">1. Introduction</span>
|
| 22 |
|
| 23 |
Nanbeige4.2-3B-Base is a new base model in the Nanbeige4 series, trained from scratch with improvements to both model architecture and training data. It delivers substantial gains over the previous generation and outperforms opensource base models of comparable scale, including Qwen3.5-4B and Gemma4-E4B, across a broad range of benchmarks. Key features include:
|
|
|
|
| 26 |
|
| 27 |
- **Enhanced Training Data Recipe**: Expands the total amount of training data from 23T to 28T tokens, with more aggressive upsampling of math, code, STEM, and Synthetic-QA data to strengthen reasoning and coding capabilities.
|
| 28 |
|
| 29 |
+
The accompanying [`modeling_nanbeige.py`](https://huggingface.co/Nanbeige/Nanbeige4.2-3B/blob/main/modeling_nanbeige.py) also includes our latest architectural improvements, including **LoopSplit**, **mHC with depth attention**, and **concatenated n-gram embeddings**. These features have been incorporated into Nanbeige4.5, whose training is underway for release later in 2026.
|
| 30 |
|
| 31 |
# <span id="Model-Performance">2. Model Performance</span>
|
| 32 |
|