Instructions to use BeardedMonster/sabiyarnMoE with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BeardedMonster/sabiyarnMoE with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="BeardedMonster/sabiyarnMoE", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("BeardedMonster/sabiyarnMoE", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use BeardedMonster/sabiyarnMoE with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "BeardedMonster/sabiyarnMoE" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BeardedMonster/sabiyarnMoE", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/BeardedMonster/sabiyarnMoE
- SGLang
How to use BeardedMonster/sabiyarnMoE 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 "BeardedMonster/sabiyarnMoE" \ --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": "BeardedMonster/sabiyarnMoE", "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 "BeardedMonster/sabiyarnMoE" \ --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": "BeardedMonster/sabiyarnMoE", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use BeardedMonster/sabiyarnMoE with Docker Model Runner:
docker model run hf.co/BeardedMonster/sabiyarnMoE
Download configuration.py from BeardedMonster/sabiyarnMoE: direct link, hf CLI and curl.
- Browser
- Download file 2.11 kB
-
https://huggingface.co/BeardedMonster/sabiyarnMoE/resolve/main/configuration.py
- Command line
-
hf download hf://BeardedMonster/sabiyarnMoE/configuration.py
-
curl -L -o configuration.py https://huggingface.co/BeardedMonster/sabiyarnMoE/resolve/main/configuration.py
2.11 kB
| from transformers import PretrainedConfig, PreTrainedModel, AutoConfig, AutoModelForCausalLM | |
| from transformers.modeling_outputs import CausalLMOutputWithPast | |
| from typing import List, Optional, Tuple | |
| from torch import nn | |
| import torch | |
| import torch.nn.functional as F | |
| import math | |
| repo_name = "BeardedMonster/SabiYarn-125M" | |
| class GPTJXMoEConfig(PretrainedConfig): | |
| """Configuration class for SabiYarn model.""" | |
| model_type = "sabiyarn" | |
| def __init__( | |
| self, | |
| block_size: int = 32768, | |
| vocab_size: int = 52050, # GPT-2 vocab_size of 50257, padded up to nearest multiple of 64 for efficiency | |
| n_layer: int = 12, | |
| n_heads: int = 12, | |
| n_embd: int = 768, | |
| dropout: float = 0.0, | |
| max_batch_size: int = 1, | |
| use_kv_cache: bool = True, | |
| bias: bool = False, # True: bias in Linears and LayerNorms, like GPT-2. False: a bit better and faster | |
| kv_cache_dtype: str = "float32", # "float32" or "float16" for memory savings | |
| # MoE hyperparameters | |
| use_moe: bool = False, # Whether to use MoE instead of dense MLP | |
| num_experts: int = 4, # Number of experts in MoE layer | |
| num_experts_per_tok: int = 2, # Number of experts to route each token to (top-k) | |
| moe_dim: int = None, # MoE hidden dimension (defaults to 4 * n_embd like MLP) | |
| **kwargs | |
| ): | |
| self.block_size = block_size | |
| self.vocab_size = vocab_size | |
| self.n_layer = n_layer | |
| self.n_heads = n_heads | |
| self.n_embd = n_embd | |
| self.dropout = dropout | |
| self.bias = bias | |
| self.use_kv_cache = use_kv_cache | |
| self.max_batch_size = max_batch_size | |
| self.kv_cache_dtype = kv_cache_dtype # Memory optimization: use float16 for cache | |
| # MoE configuration | |
| self.use_moe = use_moe | |
| self.num_experts = num_experts | |
| self.num_experts_per_tok = num_experts_per_tok | |
| # Default moe_dim to match MLP expansion (4x) | |
| self.moe_dim = moe_dim if moe_dim is not None else (4 * n_embd) | |
| super().__init__(**kwargs) | |