Doge uses Dynamic Mask Attention as sequence transformation and can use Multi-Layer Perceptron or Cross Domain Mixture of Experts as state transformation. Dynamic Mask Attention allows the Transformer to use self-attention during training and state space during inference, and Cross Domain Mixture of Experts can directly inherit the weights of Multi-Layer Perceptron for further training. This model is trained by
SmallDoge community, for detailed algorithm and model architecture, paper coming soon, all training details and code are available in the
small-doge repository.
1from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig, TextStreamer
2
3tokenizer = AutoTokenizer.from_pretrained("SmallDoge/Doge-20M-Instruct")
4model = AutoModelForCausalLM.from_pretrained("SmallDoge/Doge-20M-Instruct", trust_remote_code=True)
5
6generation_config = GenerationConfig(
7 max_new_tokens=100,
8 use_cache=True,
9 do_sample=True,
10 temperature=0.8,
11 top_p=0.9,
12 repetition_penalty=1.0
13)
14steamer = TextStreamer(
15 tokenizer=tokenizer,
16 skip_prompt=True
17)
18
19prompt = "Hi, how are you doing today?"
20conversation = [
21 {"role": "user", "content": prompt}
22]
23inputs = tokenizer.apply_chat_template(
24 conversation=conversation,
25 tokenize=True,
26 return_tensors="pt",
27)
28
29outputs = model.generate(
30 inputs,
31 tokenizer=tokenizer,
32 generation_config=generation_config,
33 streamer=steamer
34)
We build the Doge-Instruct by first SFT on
SmolTalk and then DPO on
UltraFeedback Binarized.
1@misc{smalldoges,
2 title={SmallDoges: A Family of Dynamic UltraFast Small Language Models},
3 author={Jingze, Shi and Yifan, Wu and Bingheng, Wu and Yuyu, Luo},
4 year={2025},
5 month={March},
6 url={https://github.com/SmallDoges/small-doge}
7}