Text Generation
Transformers
Safetensors
English
mixtral
mixture-of-experts
Mixture of Experts
mergekit
smollm2
instruct
reasoning
code
math
creative
Merge
conversational
text-generation-inference
Instructions to use Fu01978/SmolMoE-4x360M-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Fu01978/SmolMoE-4x360M-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Fu01978/SmolMoE-4x360M-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Fu01978/SmolMoE-4x360M-Instruct") model = AutoModelForCausalLM.from_pretrained("Fu01978/SmolMoE-4x360M-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Fu01978/SmolMoE-4x360M-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Fu01978/SmolMoE-4x360M-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Fu01978/SmolMoE-4x360M-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Fu01978/SmolMoE-4x360M-Instruct
- SGLang
How to use Fu01978/SmolMoE-4x360M-Instruct 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 "Fu01978/SmolMoE-4x360M-Instruct" \ --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": "Fu01978/SmolMoE-4x360M-Instruct", "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 "Fu01978/SmolMoE-4x360M-Instruct" \ --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": "Fu01978/SmolMoE-4x360M-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Fu01978/SmolMoE-4x360M-Instruct with Docker Model Runner:
docker model run hf.co/Fu01978/SmolMoE-4x360M-Instruct
SmolMoE-4x360M-Instruct
A Mixture-of-Experts model built by merging four SmolLM2-360M fine-tunes using mergekit. Each expert specializes in a distinct domain, with 2 experts active per token (~720M active parameters per forward pass out of ~1.4B total).
Experts
| # | Model | Specialization |
|---|---|---|
| E0 | HuggingFaceTB/SmolLM2-360M-Instruct | General knowledge, factual Q&A |
| E1 | prithivMLmods/SmolLM2-CoT-360M | Chain-of-thought reasoning, logic |
| E2 | summerstars/SolaraV2-coder-0517 | Code generation, mathematics |
| E3 | Fu01978/SmolLM2-360M-Instruct-Heretic | Creative writing, expressive language |
Architecture
- Base architecture: Mixtral-style MoE (via mergekit)
- Total experts: 4
- Active experts per token: 2
- Gate mode:
hidden(router trained on real hidden states), with subsequent router fine-tuning - Active parameters per token: ~720M
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained(
"Fu01978/SmolMoE-4x360M-Instruct",
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained("Fu01978/SmolMoE-4x360M-Instruct")
messages = [{"role": "user", "content": "Implement a binary search in Python."}]
formatted = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(formatted, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=256, temperature=0.2, do_sample=True)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Limitations
- General factual accuracy is imperfect — the model can hallucinate details on knowledge questions
- At 360M per expert, complex multi-step reasoning has limits
- E0 (General) is the weakest router target due to weight similarity with E3 (Heretic), which is a direct fine-tune of the same base
Created With
- mergekit — MoE construction
- Kaggle Dual T4 GPUs
- Downloads last month
- 28
Model tree for Fu01978/SmolMoE-4x360M-Instruct
Merge model
this model
docker model run hf.co/Fu01978/SmolMoE-4x360M-Instruct