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", device_map="auto") 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 Settings
- 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
Update README.md
Browse files
README.md
CHANGED
|
@@ -20,4 +20,77 @@ tags:
|
|
| 20 |
- math
|
| 21 |
- creative
|
| 22 |
- merge
|
| 23 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
- math
|
| 21 |
- creative
|
| 22 |
- merge
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
# SmolMoE-4x360M-Instruct
|
| 26 |
+
|
| 27 |
+
A Mixture-of-Experts model
|
| 28 |
+
built by merging four SmolLM2-360M fine-tunes
|
| 29 |
+
using [mergekit](https://github.com/arcee-ai/mergekit).
|
| 30 |
+
Each expert specializes
|
| 31 |
+
in a distinct domain,
|
| 32 |
+
with 2 experts active per token
|
| 33 |
+
(~720M active parameters
|
| 34 |
+
per forward pass
|
| 35 |
+
out of ~1.4B total).
|
| 36 |
+
|
| 37 |
+
## Experts
|
| 38 |
+
|
| 39 |
+
| # | Model | Specialization |
|
| 40 |
+
|---|-------|---------------|
|
| 41 |
+
| E0 | [HuggingFaceTB/SmolLM2-360M-Instruct](https://huggingface.co/HuggingFaceTB/SmolLM2-360M-Instruct) | General knowledge, factual Q&A |
|
| 42 |
+
| E1 | [prithivMLmods/SmolLM2-CoT-360M](https://huggingface.co/prithivMLmods/SmolLM2-CoT-360M) | Chain-of-thought reasoning, logic |
|
| 43 |
+
| E2 | [summerstars/SolaraV2-coder-0517](https://huggingface.co/summerstars/SolaraV2-coder-0517) | Code generation, mathematics |
|
| 44 |
+
| E3 | [Fu01978/SmolLM2-360M-Instruct-Heretic](https://huggingface.co/Fu01978/SmolLM2-360M-Instruct-Heretic) | Creative writing, expressive language |
|
| 45 |
+
|
| 46 |
+
## Architecture
|
| 47 |
+
|
| 48 |
+
- **Base architecture:** Mixtral-style MoE (via mergekit)
|
| 49 |
+
- **Total experts:** 4
|
| 50 |
+
- **Active experts per token:** 2
|
| 51 |
+
- **Gate mode:** `hidden` (router trained on real hidden states), with subsequent router fine-tuning
|
| 52 |
+
- **Active parameters per token:** ~720M
|
| 53 |
+
|
| 54 |
+
## Usage
|
| 55 |
+
|
| 56 |
+
```python
|
| 57 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 58 |
+
import torch
|
| 59 |
+
|
| 60 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 61 |
+
"Fu01978/SmolMoE-4x360M-Instruct",
|
| 62 |
+
torch_dtype=torch.bfloat16,
|
| 63 |
+
device_map="auto",
|
| 64 |
+
trust_remote_code=True,
|
| 65 |
+
)
|
| 66 |
+
tokenizer = AutoTokenizer.from_pretrained("Fu01978/SmolMoE-4x360M-Instruct")
|
| 67 |
+
|
| 68 |
+
messages = [{"role": "user", "content": "Implement a binary search in Python."}]
|
| 69 |
+
formatted = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 70 |
+
inputs = tokenizer(formatted, return_tensors="pt").to(model.device)
|
| 71 |
+
|
| 72 |
+
output = model.generate(**inputs, max_new_tokens=256, temperature=0.2, do_sample=True)
|
| 73 |
+
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
## Limitations
|
| 77 |
+
|
| 78 |
+
- General factual accuracy
|
| 79 |
+
is imperfect — the model can hallucinate
|
| 80 |
+
details on knowledge questions
|
| 81 |
+
- At 360M per expert,
|
| 82 |
+
complex multi-step reasoning
|
| 83 |
+
has limits
|
| 84 |
+
- E0 (General)
|
| 85 |
+
is the weakest
|
| 86 |
+
router target
|
| 87 |
+
due to weight similarity
|
| 88 |
+
with E3 (Heretic),
|
| 89 |
+
which is a direct fine-tune
|
| 90 |
+
of the same base
|
| 91 |
+
|
| 92 |
+
## Created With
|
| 93 |
+
|
| 94 |
+
- [mergekit](https://github.com/arcee-ai/mergekit)
|
| 95 |
+
— MoE construction
|
| 96 |
+
- Kaggle Dual T4 GPUs
|