Text Generation
Transformers
Safetensors
Chinese
English
samai_27b
pondernet
mixture-of-experts
adaptive-computation
multi-token-prediction
qwen3.8
conversational
custom_code
Instructions to use tchbcb/samai-27b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tchbcb/samai-27b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tchbcb/samai-27b", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("tchbcb/samai-27b", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tchbcb/samai-27b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tchbcb/samai-27b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tchbcb/samai-27b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tchbcb/samai-27b
- SGLang
How to use tchbcb/samai-27b 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 "tchbcb/samai-27b" \ --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": "tchbcb/samai-27b", "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 "tchbcb/samai-27b" \ --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": "tchbcb/samai-27b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tchbcb/samai-27b with Docker Model Runner:
docker model run hf.co/tchbcb/samai-27b
samai-27b ยท PonderNet + dMoE + MTP (Qwen3.8-27B backbone)
ๅฐ samai-4b (tchbcb/samai-4b) ็่ช้ๅบ่ฎก็ฎๆน้ ๆนๆก็งปๆคๅฐ Qwen/Qwen3.8-27B ็ 27B ๅ ๆ/ๅพๆ่ฏญ่จๆจกๅใ้ชจๅนฒๆ้ๅๆ ทไฟ็, ๆฐๅขๆจกๅๆ็จ ๅฏ็ญไปทๅๅๅๅงๅ (้ถ router = ๅๅงไธๅบๅบง้ไฝๅฏๅฏนๆ), ๅฏ็ดๆฅ่ฟๅ ฅไธๆธธ SFTใ
ๆถๆ
- ้ชจๅนฒ: Qwen3.8-27B โ 64 ๅฑๆททๅ (48 gated-delta-net ็บฟๆงๆณจๆๅ + 16 GQA ๅ จๆณจๆๅ, ๆฏ 4 ๅฑ 1 ไธช), hidden 5120, MLP 17408, vocab 248320, MPE 262144, ๅ็ๅคๆจกๆๅ ่ฃ (SigLIP ่ง่งๅก 27 ๅฑ, ๅๆ ทไฟ็ โ samai-27b ไปๆฏๅพๆๆจกๅ)
- PonderNet: ๆๅ 8 ไธชๅ จๆณจๆๅๅฑ (L35/39/43/47/51/55/59/63) ๅ่ชไธบ ponder ไฝ็น: ๅฑๅ learned-halting ๅพช็ฏ (็ฌ็ซๅๆบๅคด, bias +4.0 โ ๅๅง ฮปโ0.982 โ 2 ๆญฅ), ๆ่่ฟญไปฃ็จ"ๆฟๆขๅผ KV"่ฏญไน (่ฃๅช่ชๅฎถ KV ๆงฝไฝ้ๅ), ็ปๆญขๅ commit pass ็จๆททๅ ่กจ็คบ้ๅ KVใๅปๆๅช้ๅ จๆณจๆๅๅฑ โ ็บฟๆงๆณจๆๅๅฑ็ delta-rule ้ๅฝ็ถๆไธๅฏ้ๅ ฅ, ๅฑ็บง ponder ๅฎๅ จ็ปๅผ่ฏฅ็ถๆ, ๅฎ็ฐ้ถ็ถๆ้ฃ้ฉ
- dMoE: 8 ไธช ponder ๅฑ็ MLP ๅๆ 8 ไธๅฎถ (ๅฎฝๅบฆๅๅ 2176) + ้ถๅๅงๅ router (p=1/8 ๅ จๆฟๆดป = ็จ ๅฏ็ญไปท่ตทๆญฅ), Switch ๅผ่ด่ฝฝๅ่กก (aux = Nยทฮฃf_iยทP_i) + STE ๆขฏๅบฆ, tau=0.125
- MTP: ็ปงๆฟๅบๅบงๅ็ DeepSeek-V3 ๅผ MTP ๆ้ (fc 2HโH + pre_fc_norm_hidden/ embedding + 1 ๅฑๅ จๆณจๆๅ decoder + norm), ่ฎญ็ปๆไฝ็ฝฎ t ่พๅ ฅ [h_t, e_{t+1}] ้ขๆต t+2 (CE, mtp_loss_weight=1), ๆจ็่ชๅจๆ่ทฏ
ๅ็้ช่ฏ (่ฟทไฝ ้ๆบๆ้, 26/26 PASS)
- ็ญไปทๆง: forced_steps=1 + ้ถ router ไธๅ็ Qwen3.8 ๅฎ็ฐ้ไฝๅฏนๆ โ argmax ๅ จๅฏน, maxdiff 1.0e-06 (fp32 GEMM ๅชๅฃฐ), greedy ็ๆ token ๅบๅๅฎๅ จไธ่ด
- ่ฎญ็ป่ทฏๅพ: ไธป loss + ponder KL + MoE aux + MTP CE ๅ จ้จๆ้; router/halter/ expert/MTP ๆขฏๅบฆๅ จ้้ถ
- ๅญๅ้ญ็ฏ: save_pretrained โ trust_remote_code ้่ฝฝ, logits ้ไฝไธ่ด (0.00e+00)
ไฝฟ็จ
from transformers import AutoModelForImageTextToText, AutoTokenizer
import torch
m = AutoModelForImageTextToText.from_pretrained(
"tchbcb/samai-27b", trust_remote_code=True,
dtype=torch.bfloat16, device_map="auto")
tok = AutoTokenizer.from_pretrained("tchbcb/samai-27b")
out = m.generate(**tok.apply_chat_template(
[{"role": "user", "content": "ไฝ ๅฅฝ"}], add_generation_prompt=True,
tokenize=True, return_dict=True), max_new_tokens=256)
print(m.ponder_stats()) # ๆฏๅฑ executed ๆญฅๆฐ / ๅนณๅๆ่ๆญฅๆฐ / MoE ๆฟๆดปไธๅฎถๆฐ
AutoModelForCausalLM/AutoModelไบฆๆณจๅๅฐๅไธๅฎ็ฐ (trust_remote_code=True)- ่ฟ่กๆๅฏ่ฐ:
m.config.ponder_forced_steps=1(็ญไปทๆจกๅผ/็ด้),max_ponder_steps,commit_kv็ญ
่ฎญ็ป (SFT)
- PonderNet:
ponder_loss_betaKL ๆญฃๅ (Geometric ๅ ้ช), ๅๆบๅคด bias +4 ่ตทๆญฅ - dMoE:
moe_aux_weight่ด่ฝฝๅ่กก; router ไป้ถ่ตทๆญฅ, SFT ๅ็จ็ๅ (4b ๅฎๆต 8โ1.4~4.8) - MTP:
mtp_loss_weightๆงๅถ t+2 ้ขๆต้กน (ๆจ็ๆ่ทฏ, ไป ่พ ๅฉ่ฎญ็ป) - ๆณจๆ: 27B LoRA SFT ้ๅคๅกๆ QLoRA (T4 16GB ไธๅฏ่ก); ่ฎญ็ปๆถ้ๅผ gradient_checkpointing ( ponder ๅพช็ฏไฝฟๆฟๆดป โ K ๅ)
ๆ้ๆๆฏ่ฏดๆ
- 19 ไธช safetensors ๅ็: ๅบๅบง 18 (mlpโexperts ้ฎๆฟๆข) + extras 1 (้ถ router ร8 + halter ร8, seed 42)
- ่ฝฌๆข่ๆฌ
s27_convert.py(ๆตๅผ: ้ๅ็ ไธ่ฝฝโๆๆฏโไธไผ โๅ ้ค, ๆญ็น็ปญไผ ) - ๅ็่ๆฌ
s27_smoke.py; ๅปบๆจกไปฃ็ modeling_samai_27b.py(ๅๆไปถ, ไพ่ต transformers โฅ5.8 ็ qwen3_5 ๅ็ๅฎ็ฐ)
่ด่ฐขไธ่ฐฑ็ณป
samai-2b (r18) โ samai-4b (XHToken/Spark-X2.5-4B) โ samai-27b (Qwen3.8-27B); PonderNet ๆๆณๆบ่ช PonderNet/ACT, MoE ่ทฏ็ฑไธบ Switch ๅผ, MTP ็ปๆๅฏน้ฝ DeepSeek-V3ใ
- Downloads last month
- 25