Other
Transformers
TensorBoard
Safetensors
English
diffusion_lm
fill-mask
custom_code
tiny-llm-ablation
from-scratch
diffusion
masked-language-modeling
Eval Results (legacy)
Instructions to use d0rj/diffusion-51M-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use d0rj/diffusion-51M-base with Transformers:
# Load model directly from transformers import AutoModelForMaskedLM model = AutoModelForMaskedLM.from_pretrained("d0rj/diffusion-51M-base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
| """Configuration for DiffusionLM: masked (absorbing-state) discrete diffusion | |
| language model in the LLaDA / Diffusion-LM family (~51M params at default | |
| scale: hidden 512, 10 layers, heads 8, SwiGLU 1536, vocab 32768). | |
| Training: sample t ~ U(0, 1), mask each token independently with prob t, | |
| predict masked tokens with 1/t weighting, normalized by source token count. | |
| """ | |
| import math | |
| from transformers import PretrainedConfig | |
| class DiffusionLMConfig(PretrainedConfig): | |
| model_type = "diffusion_lm" | |
| def __init__( | |
| self, | |
| vocab_size: int = 32768, | |
| hidden_size: int = 512, | |
| intermediate_size: int = 1536, | |
| num_hidden_layers: int = 10, | |
| num_attention_heads: int = 8, | |
| head_dim: int = 64, | |
| max_position_embeddings: int = 2048, | |
| rope_theta: float = 10000.0, | |
| rms_norm_eps: float = 1e-5, | |
| attention_dropout: float = 0.0, | |
| tie_word_embeddings: bool = True, | |
| bos_token_id: int = 1, | |
| eos_token_id: int = 2, | |
| pad_token_id: int = 0, | |
| mask_token_id: int | None = None, | |
| num_diffusion_steps: int = 64, | |
| time_conditioning: str = "additive", | |
| time_conditioning_scale: float = 0.02, | |
| **kwargs, | |
| ): | |
| super().__init__( | |
| tie_word_embeddings=tie_word_embeddings, | |
| bos_token_id=bos_token_id, | |
| eos_token_id=eos_token_id, | |
| pad_token_id=pad_token_id, | |
| **kwargs, | |
| ) | |
| self.vocab_size = vocab_size | |
| self.hidden_size = hidden_size | |
| self.intermediate_size = intermediate_size | |
| self.num_hidden_layers = num_hidden_layers | |
| self.num_attention_heads = num_attention_heads | |
| self.head_dim = head_dim | |
| self.max_position_embeddings = max_position_embeddings | |
| self.rope_theta = rope_theta | |
| self.rms_norm_eps = rms_norm_eps | |
| self.attention_dropout = attention_dropout | |
| # [MASK] has a separate learned input vector, outside the output vocab. | |
| self.mask_token_id = mask_token_id if mask_token_id is not None else vocab_size | |
| self.num_diffusion_steps = num_diffusion_steps | |
| if time_conditioning not in ('additive', 'normalized', 'none'): | |
| raise ValueError('Unknown diffusion time conditioning') | |
| if not math.isfinite(time_conditioning_scale) or time_conditioning_scale < 0: | |
| raise ValueError('Time conditioning scale must be finite and nonnegative') | |
| self.time_conditioning = time_conditioning | |
| self.time_conditioning_scale = time_conditioning_scale | |