Instructions to use JIRU-W/top1moe-0.6b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use JIRU-W/top1moe-0.6b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="JIRU-W/top1moe-0.6b", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("JIRU-W/top1moe-0.6b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use JIRU-W/top1moe-0.6b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "JIRU-W/top1moe-0.6b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "JIRU-W/top1moe-0.6b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/JIRU-W/top1moe-0.6b
- SGLang
How to use JIRU-W/top1moe-0.6b 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 "JIRU-W/top1moe-0.6b" \ --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": "JIRU-W/top1moe-0.6b", "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 "JIRU-W/top1moe-0.6b" \ --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": "JIRU-W/top1moe-0.6b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use JIRU-W/top1moe-0.6b with Docker Model Runner:
docker model run hf.co/JIRU-W/top1moe-0.6b
Top1MoE-0.6B
OLMoE-1B-7B-0924 weights with top-1 routing hard-wired. 64 experts per layer, exactly one expert active per token. Total parameters 6.92B, active parameters per token 0.58B (top-8 upstream: 1.28B), hence "0.6B".
This repository ships its own model code (model_type = "top1moe", classes Top1MoeConfig,
Top1MoeForCausalLM, ...). Load it with trust_remote_code=True. It requires transformers >= 5.0
(the code is derived from transformers 5.3.0 internals and raises a clear ImportError on 4.x).
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "JIRU-W/top1moe-0.6b"
tok = AutoTokenizer.from_pretrained(repo, trust_remote_code=True) # tokenizer itself is the stock OLMoE one
model = AutoModelForCausalLM.from_pretrained(
repo, trust_remote_code=True, dtype=torch.bfloat16, device_map="cuda")
inputs = tok("The capital of France is", return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=16, do_sample=False)
print(tok.decode(out[0], skip_special_tokens=True))
AutoConfig / AutoModel / AutoModelForCausalLM are all mapped through auto_map in config.json.
After one trust_remote_code=True load, transformers has registered the classes in the current process,
so model.save_pretrained(...) and model.push_to_hub(...) keep the custom code.
What "top-1 hard-wired" means
Three independent enforcement points, so the model cannot silently become top-k > 1:
configuration_top1moe.py:FORCED_TOP_K = 1;Top1MoeConfig.__setattr__coercesnum_experts_per_tokto 1 on every path (constructor,config.json,from_pretrained(..., num_experts_per_tok=8), later assignment), logging a warning.modeling_top1moe.py:Top1MoeRouter.top_k = FORCED_TOP_K(never reads the config); the routing op istorch.topk(softmax(logits), 1).Top1MoeForCausalLM.num_experts_per_tok = FORCED_TOP_K(used by the load-balancing auxiliary loss).
norm_topk_prob stays false as upstream: the single expert's output is scaled by its softmax probability.
(Setting it to true, i.e. weight 1.0, was measured to be much worse: NLL 11.3 vs 4.5 on a short probe.)
Important: these weights were trained with top-8
The weights are byte-for-byte the upstream OLMoE-1B-7B-0924 checkpoint, only re-saved in the fused
expert layout (experts.gate_up_proj of shape [64, 2048, 2048], experts.down_proj of shape
[64, 2048, 1024]). Running them with one expert per token degrades them heavily:
| probe (two short texts, bf16) | NLL |
|---|---|
| upstream OLMoE-1B-7B-0924, top-8 | 0.997 |
| this model, top-1 | 4.498 |
Greedy generation is not coherent out of the box. Treat this checkpoint as a starting point for top-1 continued training / routing experiments, not as a ready-to-use 0.6B language model.
Validation
- Logits are bit-identical (max abs diff 0.0) to transformers' built-in
OlmoeForCausalLMloaded from the upstream checkpoint withnum_experts_per_tok=1. from_pretrainedreports 0 missing / 0 unexpected / 0 mismatched keys.- All 16 routers emit index tensors of shape
(tokens, 1).
Files
| file | content |
|---|---|
configuration_top1moe.py |
Top1MoeConfig, FORCED_TOP_K |
modeling_top1moe.py |
Top1MoeForCausalLM, Top1MoeModel, router / experts / attention modules |
config.json |
architecture hyper-parameters (OLMoE-1B-7B), num_experts_per_tok: 1, auto_map |
model-0000*-of-00003.safetensors, model.safetensors.index.json |
bf16 weights, fused expert layout |
tokenizer.json, tokenizer_config.json, special_tokens_map.json |
upstream OLMoE tokenizer |
generation_config.json |
upstream generation defaults |
Provenance
- Weights: allenai/OLMoE-1B-7B-0924, commit
6d84c48581ece794365f2b8e9cfb043c68ade9c5, Apache-2.0. - Code: derived from
transformers==5.3.0models/olmoe/{configuration,modeling}_olmoe.py(Apache-2.0), with the class renames and the top-1 enforcement described above. Attention, RoPE, norms, expert MLPs and the loss are unchanged.
中文说明
这是 OLMoE-1B-7B-0924 的原权重,把 top-k 硬编码成 top-1(每 token 只激活 1 个 expert,激活参数 0.58B)。
代码是自带的(model_type="top1moe",类名 Top1Moe*),用 trust_remote_code=True 加载,需要
transformers>=5.0。权重是按 top-8 训的,直接 top-1 推理退化明显(NLL 4.5 对 1.0),适合当 top-1 续训或
路由实验的起点。强制 top-1 的三个点和验证结果见上文。
- Downloads last month
- 40
Model tree for JIRU-W/top1moe-0.6b
Base model
allenai/OLMoE-1B-7B-0924