Text Generation
Transformers
Safetensors
English
slim_moe
MoE
Text-Generation
Instruction Following
VGQA
Research
SLM
custom_code
Instructions to use SlimFactoryHub/SlimMoE-250M-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SlimFactoryHub/SlimMoE-250M-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="SlimFactoryHub/SlimMoE-250M-base", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("SlimFactoryHub/SlimMoE-250M-base", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use SlimFactoryHub/SlimMoE-250M-base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "SlimFactoryHub/SlimMoE-250M-base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SlimFactoryHub/SlimMoE-250M-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/SlimFactoryHub/SlimMoE-250M-base
- SGLang
How to use SlimFactoryHub/SlimMoE-250M-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 "SlimFactoryHub/SlimMoE-250M-base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SlimFactoryHub/SlimMoE-250M-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "SlimFactoryHub/SlimMoE-250M-base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SlimFactoryHub/SlimMoE-250M-base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use SlimFactoryHub/SlimMoE-250M-base with Docker Model Runner:
docker model run hf.co/SlimFactoryHub/SlimMoE-250M-base
| from transformers import PretrainedConfig | |
| class SlimMoEConfig(PretrainedConfig): | |
| model_type = "slim_moe" | |
| def __init__( | |
| self, | |
| vocab_size: int = 50257, | |
| dim: int = 768, | |
| num_hidden_layers: int = 12, | |
| num_heads: int = 12, | |
| hidden_dim: int = 2048, | |
| num_experts: int = 4, | |
| max_seq_len: int = 2048, | |
| dropout: float = 0.1, | |
| adaptive_routing: bool = True, | |
| **kwargs | |
| ): | |
| self.vocab_size = vocab_size | |
| self.dim = dim | |
| self.num_hidden_layers = num_hidden_layers | |
| self.num_heads = num_heads | |
| self.hidden_dim = hidden_dim | |
| self.num_experts = num_experts | |
| self.max_seq_len = max_seq_len | |
| self.dropout = dropout | |
| self.adaptive_routing = adaptive_routing | |
| # --- FIX: Enable automatic weight tying by the framework --- | |
| # This tells the PreTrainedModel's post_init to handle the tie correctly. | |
| self.tie_word_embeddings = True | |
| super().__init__(**kwargs) | |
| def for_250m(cls, vocab_size: int = 50257, max_seq_len: int = 2048, dropout: float = 0.1): | |
| """ | |
| Create configuration for ~300M parameter model. | |
| Uses: dim=768, layers=16, heads=12, hidden_dim=1536, experts=4 | |
| This yields approximately 280-290M parameters, safely under 250M. | |
| """ | |
| return cls( | |
| vocab_size=vocab_size, | |
| dim=768, | |
| num_hidden_layers=16, | |
| num_heads=12, | |
| hidden_dim=1536, | |
| num_experts=4, | |
| max_seq_len=max_seq_len, | |
| dropout=dropout | |
| ) |