Instructions to use Zigeng/DMax-Math-16B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Zigeng/DMax-Math-16B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Zigeng/DMax-Math-16B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Zigeng/DMax-Math-16B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Zigeng/DMax-Math-16B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Zigeng/DMax-Math-16B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Zigeng/DMax-Math-16B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Zigeng/DMax-Math-16B
- SGLang
How to use Zigeng/DMax-Math-16B 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 "Zigeng/DMax-Math-16B" \ --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": "Zigeng/DMax-Math-16B", "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 "Zigeng/DMax-Math-16B" \ --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": "Zigeng/DMax-Math-16B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Zigeng/DMax-Math-16B with Docker Model Runner:
docker model run hf.co/Zigeng/DMax-Math-16B
| """LLaDA2 MoE model configuration""" | |
| from transformers.configuration_utils import PretrainedConfig | |
| class LLaDA2MoeConfig(PretrainedConfig): | |
| model_type = "llada2_moe" | |
| def __init__( | |
| self, | |
| vocab_size=30592, | |
| hidden_size=1024, | |
| intermediate_size=None, | |
| num_hidden_layers=24, | |
| num_attention_heads=16, | |
| num_key_value_heads=0, | |
| hidden_act="silu", | |
| use_qkv_bias=False, # llada2 only | |
| use_qk_norm=True, | |
| use_bias=True, # llada2 only | |
| rms_norm_eps=1e-05, | |
| norm_head=False, # llada2 only | |
| tie_word_embeddings=False, # PretrainedConfig key, here change default value. | |
| embedding_dropout=0.1, | |
| attention_dropout=0.1, | |
| output_dropout=0.1, | |
| initializer_range=0.02, | |
| max_position_embeddings=16384, | |
| rope_theta=10000.0, | |
| use_cache=True, | |
| use_sliding_window=False, | |
| sliding_window=4096, | |
| max_window_layers=28, | |
| rope_scaling=None, | |
| pad_token_id=126081, | |
| num_experts=16, | |
| num_shared_experts=0, | |
| num_experts_per_tok=2, | |
| n_group=8, | |
| topk_group=4, | |
| routed_scaling_factor=2.5, | |
| moe_intermediate_size=None, | |
| first_k_dense_replace=0, | |
| head_dim=None, | |
| output_router_logits=False, | |
| partial_rotary_factor=0.5, | |
| **kwargs, | |
| ): | |
| self.num_hidden_layers = num_hidden_layers | |
| self.vocab_size = vocab_size | |
| self.hidden_size = hidden_size | |
| self.intermediate_size = intermediate_size | |
| self.num_attention_heads = num_attention_heads | |
| self.num_key_value_heads = num_key_value_heads | |
| self.hidden_act = hidden_act | |
| self.use_qkv_bias = use_qkv_bias | |
| self.use_qk_norm = use_qk_norm | |
| self.use_bias = use_bias | |
| self.norm_head = norm_head | |
| self.rms_norm_eps = rms_norm_eps | |
| self.embedding_dropout = embedding_dropout | |
| self.attention_dropout = attention_dropout | |
| self.output_dropout = output_dropout | |
| self.initializer_range = initializer_range | |
| self.max_position_embeddings = max_position_embeddings | |
| self.rope_theta = rope_theta | |
| self.use_cache = use_cache | |
| self.use_sliding_window = use_sliding_window | |
| self.sliding_window = sliding_window | |
| self.max_window_layers = max_window_layers | |
| self.head_dim = head_dim or self.hidden_size // self.num_attention_heads | |
| self.rope_scaling = rope_scaling | |
| # MoE configs | |
| self.num_experts = num_experts | |
| self.num_shared_experts = num_shared_experts | |
| self.num_experts_per_tok = num_experts_per_tok | |
| self.n_group = n_group | |
| self.topk_group = topk_group | |
| self.moe_intermediate_size = moe_intermediate_size | |
| self.first_k_dense_replace = first_k_dense_replace | |
| self.output_router_logits = output_router_logits | |
| self.routed_scaling_factor = routed_scaling_factor | |
| self.partial_rotary_factor = partial_rotary_factor | |
| super().__init__( | |
| pad_token_id=pad_token_id, tie_word_embeddings=tie_word_embeddings, **kwargs | |
| ) | |