Text Generation
Transformers
Safetensors
udream
Mixture of Experts
mixture-of-experts
ukrainian
nope
sliding-window-attention
from-scratch
custom_code
Instructions to use UDream/UDream-1.0-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use UDream/UDream-1.0-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="UDream/UDream-1.0-Base", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("UDream/UDream-1.0-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use UDream/UDream-1.0-Base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "UDream/UDream-1.0-Base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "UDream/UDream-1.0-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/UDream/UDream-1.0-Base
- SGLang
How to use UDream/UDream-1.0-Base 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 "UDream/UDream-1.0-Base" \ --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": "UDream/UDream-1.0-Base", "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 "UDream/UDream-1.0-Base" \ --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": "UDream/UDream-1.0-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use UDream/UDream-1.0-Base with Docker Model Runner:
docker model run hf.co/UDream/UDream-1.0-Base
Download configuration_udream.py from UDream/UDream-1.0-Base: direct link, hf CLI and curl.
- Browser
- Download file 3.23 kB
-
https://huggingface.co/UDream/UDream-1.0-Base/resolve/main/configuration_udream.py
- Command line
-
hf download hf://UDream/UDream-1.0-Base/configuration_udream.py
-
curl -L -o configuration_udream.py https://huggingface.co/UDream/UDream-1.0-Base/resolve/main/configuration_udream.py
3.23 kB
| # coding=utf-8 | |
| """UDream 1.0 model configuration for Hugging Face Transformers.""" | |
| from transformers import PretrainedConfig | |
| class UDreamConfig(PretrainedConfig): | |
| """Configuration class for UDream 1.0 (Sparse MoE + 5:1 SWA/NoPE + 8D Hormones).""" | |
| model_type = "udream" | |
| def __init__( | |
| self, | |
| vocab_size: int = 64128, | |
| d_model: int = 2048, | |
| n_layers: int = 26, | |
| n_heads: int = 16, | |
| n_kv_heads: int = 4, | |
| head_dim: int = 128, | |
| global_every: int = 6, | |
| window: int = 512, | |
| rope_theta: float = 10000.0, | |
| dense_d_ff: int = 5632, | |
| n_dense_first: int = 2, | |
| n_dense_last: int = 2, | |
| n_experts: int = 32, | |
| expert_d_ff: int = 768, | |
| moe_top_k: int = 6, | |
| shared_d_ff: int = 2048, | |
| n_hormones: int = 8, | |
| cond_dim: int = 256, | |
| hormone_dropout: float = 0.1, | |
| z_loss: float = 1e-4, | |
| lb_loss: float = 1e-2, | |
| dropout: float = 0.0, | |
| rms_eps: float = 1e-5, | |
| init_std: float = 0.02, | |
| tie_embeddings: bool = True, | |
| max_position_embeddings: int = 32768, | |
| bos_token_id: int = 1, | |
| eos_token_id: int = 2, | |
| pad_token_id: int = 0, | |
| unk_token_id: int = 3, | |
| **kwargs, | |
| ): | |
| # Accept legacy ckpt `top_k` without polluting HF GenerationConfig.top_k sampling parameter | |
| if "top_k" in kwargs: | |
| moe_top_k = kwargs.pop("top_k") | |
| self.vocab_size = vocab_size | |
| self.d_model = d_model | |
| self.n_layers = n_layers | |
| self.n_heads = n_heads | |
| self.n_kv_heads = n_kv_heads | |
| self.head_dim = head_dim | |
| self.global_every = global_every | |
| self.window = window | |
| self.rope_theta = rope_theta | |
| self.dense_d_ff = dense_d_ff | |
| self.n_dense_first = n_dense_first | |
| self.n_dense_last = n_dense_last | |
| self.n_experts = n_experts | |
| self.expert_d_ff = expert_d_ff | |
| self.moe_top_k = moe_top_k | |
| self.shared_d_ff = shared_d_ff | |
| self.n_hormones = n_hormones | |
| self.cond_dim = cond_dim | |
| self.hormone_dropout = hormone_dropout | |
| self.z_loss = z_loss | |
| self.lb_loss = lb_loss | |
| self.dropout = dropout | |
| self.rms_eps = rms_eps | |
| self.init_std = init_std | |
| self.tie_embeddings = tie_embeddings | |
| self.max_position_embeddings = max_position_embeddings | |
| # Standard HF convenience aliases | |
| self.hidden_size = d_model | |
| self.num_hidden_layers = n_layers | |
| self.num_attention_heads = n_heads | |
| self.num_key_value_heads = n_kv_heads | |
| kwargs.setdefault("tie_word_embeddings", tie_embeddings) | |
| super().__init__( | |
| bos_token_id=bos_token_id, | |
| eos_token_id=eos_token_id, | |
| pad_token_id=pad_token_id, | |
| unk_token_id=unk_token_id, | |
| **kwargs, | |
| ) | |
| def is_global(self, layer: int) -> bool: | |
| """Every `global_every`-th layer (1-indexed: 6, 12, 18, 24 -> 0-idx 5, 11, 17, 23) is NoPE global.""" | |
| return (layer + 1) % self.global_every == 0 | |
| def is_moe(self, layer: int) -> bool: | |
| return self.n_dense_first <= layer < self.n_layers - self.n_dense_last | |