Beyond Magnitude: Contrastive Routing for Modular Mixture-of-Experts
Paper • 2609.01100 • Published • 1
How to use ilsp/CoRM-469M-top1 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="ilsp/CoRM-469M-top1", trust_remote_code=True) # Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("ilsp/CoRM-469M-top1", trust_remote_code=True, device_map="auto")How to use ilsp/CoRM-469M-top1 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "ilsp/CoRM-469M-top1"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "ilsp/CoRM-469M-top1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/ilsp/CoRM-469M-top1
How to use ilsp/CoRM-469M-top1 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "ilsp/CoRM-469M-top1" \
--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": "ilsp/CoRM-469M-top1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "ilsp/CoRM-469M-top1" \
--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": "ilsp/CoRM-469M-top1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use ilsp/CoRM-469M-top1 with Docker Model Runner:
docker model run hf.co/ilsp/CoRM-469M-top1
Contrastive Routing Mixture-of-Experts (CoRM). Checkpoint for the paper Beyond Magnitude: Contrastive Routing for Modular Mixture-of-Experts.
Part of the ilsp/CoRM collection.
| Model | Active Params | Total Params | Routing |
|---|---|---|---|
| CoRM-469M-top1 | 469M | 2.58B | Top-1 |
| Hidden size | 1024 |
| Layers | 24 |
| Attention heads | 16 (4 KV heads, GQA) |
| Intermediate size | 4096 |
| Experts | 8 |
| Experts per token | 1 |
| Vocab size | 51200 |
| Max position embeddings | 1024 |
| Dtype | bfloat16 |
This model uses custom modeling code, so trust_remote_code=True is required.
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "ilsp/CoRM-469M-top1"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True)
inputs = tokenizer("The capital of Greece is", return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=32)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))